Skip to content

fix: log fetch failure#532

Open
fredericDelaporte wants to merge 1 commit into
atinux:mainfrom
fredericDelaporte:fix-swallowed-ex
Open

fix: log fetch failure#532
fredericDelaporte wants to merge 1 commit into
atinux:mainfrom
fredericDelaporte:fix-swallowed-ex

Conversation

@fredericDelaporte

@fredericDelaporte fredericDelaporte commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Help diagnose #488

Summary by CodeRabbit

  • Improvements
    • Enhanced error logging for session request failures to aid troubleshooting.

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

In useUserSession, the fetch helper's .catch() callback is updated to receive and log the rejection reason via console.log before returning null. No exported API signatures, session state logic, or request/response behavior is changed.

Changes

Session Fetch Error Logging

Layer / File(s) Summary
Log rejection reason in session fetch
src/runtime/app/composables/session.ts
The .catch(() => null) callback is replaced with .catch((reason) => { console.log(reason); return null; }), surfacing fetch errors to the console while preserving the existing null-return behavior.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐇 A silent catch no more, I say,
The error hops out into the light of day!
With console.log it leaps right through,
The reason printed, plain in view.
No secret fails shall slip away~

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: log fetch failure' directly and accurately describes the main change: adding logging for fetch failures in the session composable.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/runtime/app/composables/session.ts`:
- Line 35: The arrow function parameter in the `.catch()` method violates the
`@stylistic/arrow-parens` linting rule. Wrap the single parameter `reason` in
parentheses by changing `.catch(reason => {` to `.catch((reason) => {` to comply
with the linting requirement.
- Around line 35-37: The catch handler in the session composable is logging the
raw rejection reason object directly, which can expose sensitive authentication
and session details in logs. Replace the direct logging of the raw `reason`
parameter with a sanitized error message that does not include sensitive
information. If error details are needed for development debugging, consider
logging only safe, minimal information and only when in development mode, while
production should use a generic safe message.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7aa40195-9031-47cf-b88d-9a10c947b1d6

📥 Commits

Reviewing files that changed from the base of the PR and between ceb366b and 5999ed6.

📒 Files selected for processing (1)
  • src/runtime/app/composables/session.ts

},
retry: false,
}).catch(() => null)
}).catch(reason => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix lint error for arrow function parentheses.

Line 35 currently violates @stylistic/arrow-parens; this can fail lint/CI.

Minimal lint fix
-    }).catch(reason => {
+    }).catch((reason) => {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
}).catch(reason => {
}).catch((reason) => {
🧰 Tools
🪛 ESLint

[error] 35-35: Expected parentheses around arrow function argument having a body with curly braces.

(@stylistic/arrow-parens)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/runtime/app/composables/session.ts` at line 35, The arrow function
parameter in the `.catch()` method violates the `@stylistic/arrow-parens`
linting rule. Wrap the single parameter `reason` in parentheses by changing
`.catch(reason => {` to `.catch((reason) => {` to comply with the linting
requirement.

Source: Linters/SAST tools

Comment on lines +35 to +37
}).catch(reason => {
console.log('Failure on fetching session', reason)
return null

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid logging raw fetch rejection objects.

At Line 36, logging reason directly can leak sensitive auth/session error details into client/server logs. Prefer a sanitized message (and only include minimal safe fields in development mode).

Suggested safer pattern
-    }).catch(reason => {
-      console.log('Failure on fetching session', reason)
+    }).catch((reason) => {
+      const message = reason instanceof Error ? reason.message : String(reason)
+      if (import.meta.dev) {
+        console.error('Failure on fetching session:', message)
+      }
       return null
     })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
}).catch(reason => {
console.log('Failure on fetching session', reason)
return null
}).catch((reason) => {
const message = reason instanceof Error ? reason.message : String(reason)
if (import.meta.dev) {
console.error('Failure on fetching session:', message)
}
return null
})
🧰 Tools
🪛 ESLint

[error] 35-35: Expected parentheses around arrow function argument having a body with curly braces.

(@stylistic/arrow-parens)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/runtime/app/composables/session.ts` around lines 35 - 37, The catch
handler in the session composable is logging the raw rejection reason object
directly, which can expose sensitive authentication and session details in logs.
Replace the direct logging of the raw `reason` parameter with a sanitized error
message that does not include sensitive information. If error details are needed
for development debugging, consider logging only safe, minimal information and
only when in development mode, while production should use a generic safe
message.

}).catch(() => null)
}).catch(reason => {
console.log('Failure on fetching session', reason)
return null

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may somewhat fix the issue by yielding sessionState.value here instead of null. It would allow to preserve the session state on fetch failure, instead of losing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant