-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: prevent route crash when subscription or permissions prefetch fails #6047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
devin-ai-integration
wants to merge
1
commit into
main
Choose a base branch
from
devin/1776276354-fix-access-management-undefined-component
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+13
−8
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 The
Promise.allSettledresult is never inspected, so rejections fromfetchOrgSubscriptionorfetchUserOrgPermissionsare completely silent — no logging, no alerting — despite an analogousconsole.warnalready existing at line 58 for similar non-fatal failures. Additionally, the comment on lines 68–70 says these components use "useQuery hooks that will retry independently", but bothSubscriptionContext.tsxandOrgPermissionContext.tsxactually useuseSuspenseQuery, which throws to the nearest React error boundary on persistent failure rather than silently retrying; users who hit a persistent error land onErrorPage, which has only a "Back To Home" link with no retry button.Extended reasoning...
Issue 1: Silent rejection swallowing
The
await Promise.allSettled([...])on line 71 discards the returnedPromiseSettledResult[]array entirely — the result is never bound to a variable and never inspected. This means iffetchOrgSubscriptionorfetchUserOrgPermissionsrejects (e.g. due to a network error, a broken license endpoint on a self-hosted instance, or an auth hiccup), the failure is completely invisible: no console output, no metrics, no alerting. The PR description itself calls this out: 'Promise.allSettled swallows rejections without logging. Consider whether a console.warn on rejected results would aid future debugging.'Why existing code does not prevent it: The same file already has an established pattern for non-fatal failures. At line 58, the token-exchange catch block emits
console.warn("Failed to automatically exchange token for organization:", error). ThePromise.allSettledblock is directly analogous — intentionally non-fatal — yet omits any equivalent logging. The inconsistency means subscription/permission prefetch failures are invisible while token-exchange failures are surfaced.Concrete proof of the gap: Suppose
fetchOrgSubscriptionrejects with a 500 from the license endpoint.Promise.allSettledcatches the rejection internally and stores{ status: 'rejected', reason: Error(...) }in the results array. Because that array is immediately discarded, the error is gone. The route continues loading. No developer — in local dev, staging, or production — has any signal that the prefetch failed. Filtering rejected results and emitting aconsole.warn(matching the pattern at line 58) would surface these failures for free.Issue 2: Inaccurate comment — useSuspenseQuery vs useQuery
The comment on lines 68–70 reads: "the components using this data have their own useQuery hooks that will retry independently." Both downstream context files use
useSuspenseQuery, notuseQuery. These hooks have fundamentally different failure semantics:useQueryreturns{ status: 'error' }and lets the component decide how to render;useSuspenseQuerythrows the error to the nearest React error boundary on persistent failure. Withretry: 1configured on the QueryClient, if both the prefetch and a single component-level retry fail,useSuspenseQuerythrows to the router'sdefaultErrorComponent: ErrorPage. TheErrorPagecomponent only renders a "Back To Home" link — no retry button — leaving users stuck.Why this matters beyond a nit: The phrase "retry independently" implies graceful, silent recovery. A future maintainer relying on this comment might not add proper error handling (e.g. an error boundary with a retry button at the subscription/permission level), assuming the hooks silently recover. The comment should accurately describe that
useSuspenseQueryis in use and that persistent failures surface to the error boundary.Suggested fix: (1) Capture and inspect the
Promise.allSettledresults, logging any rejections viaconsole.warnconsistent with line 58. (2) Update the comment to accurately stateuseSuspenseQueryis used and that persistent failures throw to the error boundary rather than silently retrying.