feat: improve error handling for expired pending session#3091
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
📝 WalkthroughWalkthroughThis update refines error handling in the dashboard authentication flow. In the auth actions, a generic error in the Changes
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (2)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Thank you for following the naming conventions for pull request titles! 🙏 |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/dashboard/app/auth/sign-in/org-selector.tsx (1)
44-61: Robust error handling implementation.The try-catch-finally structure provides comprehensive error handling for both API response errors and exceptions. The error message differentiation between Error instances and other errors is a good practice.
Two minor suggestions for consideration:
- The hardcoded support email in the fallback error message could be moved to a constants file to maintain DRY principles if used elsewhere.
- You might want to add logging for unexpected errors to help with debugging.
try { const result = await completeOrgSelection(selected); if (!result.success) { onError(result.message); } return; } catch (error) { + // Log unexpected errors for debugging + console.error('Error during organization selection:', error); const errorMessage = error instanceof Error ? error.message : "Failed to complete organization selection. Please re-authenticate or contact support@unkey.dev"; onError(errorMessage); } finally { setIsOpen(false); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/dashboard/app/auth/sign-in/org-selector.tsx(2 hunks)apps/dashboard/lib/auth/types.ts(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/dashboard/lib/auth/types.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/dashboard/app/auth/sign-in/org-selector.tsx (2)
apps/dashboard/app/auth/actions.ts (1)
completeOrgSelection(159-178)apps/dashboard/lib/auth/workos.ts (1)
completeOrgSelection(716-754)
🔇 Additional comments (2)
apps/dashboard/app/auth/sign-in/org-selector.tsx (2)
25-25: Good addition of error handling prop.Adding the
onErrorcallback prop provides a clear and type-safe mechanism for error propagation to the parent component, which aligns perfectly with the PR's objective to improve error handling for expired sessions.
28-28: LGTM!The component signature is properly updated to destructure and use the new
onErrorprop.
|
What's your vercel log say? |
|
Shows in the logs for vercel. |
|
I feel like this a funky staging issue |
|
:thinkies: |
|
Server components don't just become funky in staging, this would be the same in production... It's probably because the error gets swallowed incorrectly. |
|
I'm glad we caught it then 😄 |
|
This is why we test in staging :D |
|
Instead of just yeeting to prod |
|
It's because the error is a 500... |
|
So when it's returned it thinks it's a server component error is my guess. |
|
btw its not being triggered until I close the dialog myself. maybe that helps |
|
That is how it would work. User sits at the screen comes back, clicks "my org" it would return the error to please login again. |
|
but in the pr description it was saying dialog closes automatically bla bla thats why I said this |
|
Ah you did not read. "The organization selector dialog closes without indication of an error or any messaging as to why the authentication did not complete. |
|
shiitt sorry maybe I'm too sleepy 😄 |
|
I'll change the action to not throw when there's no pending token, and use an error response instead |
|
One sec |
|
:chef_kissing_fingers_intensifies: |
|
:lfg: |

What does this PR do?
Fixes Linear ENG-1704
When a user has multiple organizations/workspaces, and they do not select a workspace with which to authenticate within 60 seconds, the pending session cookie expires. The organization selector dialog closes without indication of an error or any messaging as to why the authentication did not complete.
This PR adds appropriate error handling to alert the user to the condition and prompts them to re-authenticate.
Type of change
How should this be tested?
Checklist
Required
pnpm buildpnpm fmtconsole.logsgit pull origin mainAppreciated
Summary by CodeRabbit