Clear flow components and additional data on flow state reset - #50
Open
PasinduYeshan wants to merge 1 commit into
Open
Clear flow components and additional data on flow state reset#50PasinduYeshan wants to merge 1 commit into
PasinduYeshan wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThe sign-in flow cleanup now clears the execution ID, rendered flow components, and additional data when the flow state is expired or invalid. ChangesSign-in flow cleanup
Estimated code review effort: 1 (Trivial) | ~2 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@packages/react/src/components/presentation/auth/SignIn/SignIn.tsx`:
- Around line 325-327: Update handleOAuthError and the useOAuthCallback.onError
callback to await the asynchronous clearFlowState cleanup before calling
setError, ensuring isFlowInitialized cannot be reset after the error state is
presented; alternatively, move the synchronous cleanup updates before the first
await while preserving the existing error UI behavior.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: eec142cb-dddb-440e-acbf-0c6779a452b4
📒 Files selected for processing (1)
packages/react/src/components/presentation/auth/SignIn/SignIn.tsx
clearFlowState nulled the executionId but left the rendered step in place, so a terminal failure kept a form that submits into a null executionId and a stale stepTimeout that could overwrite the real error with a timeout message. Components are only ever set together with a non-null executionId, so clear them together. Apply the whole reset synchronously, before the first await, so callers that do not await clearFlowState still complete it ahead of the setError that follows.
PasinduYeshan
force-pushed
the
fix/clear-components-on-terminal-flow-error
branch
from
August 3, 2026 13:02
6546238 to
6c3d69e
Compare
Contributor
Author
|
Should be merged after following PR |
ThaminduDilshan
approved these changes
Aug 4, 2026
brionmario
approved these changes
Aug 4, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Purpose
clearFlowState()nulled theexecutionIdbut left the rendered step incomponents. On a terminal failure the previous step stayed on screen, which meant:throw new Error('No active flow ID'), which sits before thetryblock inhandleSubmitand so surfaced as an unhandled rejection rather than an error the UI could show;additionalData.stepTimeoutis an absolute timestamp, and sincesetErrorflipsisFlowInitializedback totrue, the timeout effect could re-fire withremaining <= 0and overwrite the real error with "Time allowed to complete the step has expired."Consumers also had no way to distinguish "flow is dead" from "still loading", because an error with a stale
componentsarray looks identical to a recoverable one.Approach
Clear
componentsandadditionalDatainsideclearFlowState()rather than patching individual catch sites, and apply the whole reset synchronously ahead of the firstawait.Why clearing alongside a null
executionIdis correct.setComponentshas three call sites: the clear itself,initializeFlowsuccess, andhandleSubmitsuccess. Both populate sites sit insideif (normalizedExecutionId && normalizedComponents)and are immediately preceded bysetExecutionId(normalizedExecutionId)— components are only ever populated together with a non-nullexecutionId.clearFlowStatewas the only placeexecutionIdwent null while components could remain non-empty, so clearing them together restores that invariant.The one branch that sets an
executionIdwithout touching components is the recoverable case inhandleTerminalResponse(flowStatus=ERRORwith anexecutionId— session still alive, form deliberately kept up for retry). It does not callclearFlowState, so it is unaffected.Why the reset moved before the
await.setErrorsetsisFlowInitialized = true, and the initialization effect is gated on!isFlowInitialized. Three of the five callers (handleTerminalResponseterminal branch, theinitializeFlowcatch, and thehandleSubmitcatch) awaitclearFlowState(), so the reset lands first andsetErrorwins. The other two —handleOAuthErroranduseOAuthCallback.onError— do not await it. WithsetIsFlowInitialized(false)sitting afterawait setChallengeToken(null), it ran a microtask aftersetError, sofalsewon: the effect re-fired,initializeFlowransetFlowError(null), and the user saw the error flash before being dropped back on a fresh form.Doing the whole reset synchronously makes all five callers behave identically — the flow state is cleared, then
setErrormarks the flow initialized so the error renders, and no implicit re-initialization is triggered. Components are repopulated only by an explicitinitialize()from the render props or a fresh page load, both of which go throughinitializeFlowand setexecutionIdandcomponentstogether.Related Issues
Related PRs
Checklist
Security checks