fix(login): don't cancel login saga on 2s timeout (#7333)#7340
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🧰 Additional context used📓 Path-based instructions (2)**/*.{js,ts,jsx,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (1)📚 Learning: 2026-05-07T13:19:52.152ZApplied to files:
🔇 Additional comments (1)
WalkthroughThe login root saga's task cancellation logic is now conditional. The ChangesLogin Saga Task Cancellation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested labels
Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
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 |
The cancel in login.js root() fired whichever arm of the race won, so handleLoginSuccess had a hard 2-second deadline. When fetchPermissions or fetchEnterpriseModules ran long, the saga was killed before appStart(ROOT_INSIDE), leaving users on the login screen until they retried. Only cancel when SERVER.SELECT_REQUEST (workspace switch) wins; let the timeout just bound the guard's listening window. Fixes #7333
1d751aa to
bd10b38
Compare
|
iOS Build Available Rocket.Chat 4.73.0.108946 |
Proposed changes
The
root()watcher inapp/sagas/login.jsracedSERVER.SELECT_REQUESTagainst a 2-seconddelay, thencanceledhandleLoginSuccessunconditionally — whichever arm of the race won. The cancel was meant only as a guard against a workspace switch interrupting login mid-flow, but as written it imposed a hard 2-second deadline on the saga.Inside
handleLoginSuccess, two awaited REST calls run beforeappStart(ROOT_INSIDE):On a slow network / fresh install / large permission set, those exceed 2s, the saga is cancelled before navigation, and the user is stranded on the login screen. A retry succeeds because permissions are cached and the server is warm. Matches the symptom in #7333 and the Android variant reported in the same thread (home stack flashes for ~1s, then bounces back to login).
Regression introduced by the VoIP feature PR (#6918), which switched the two fetches from
forktocall. The follow-up VoIP PR (#7270) noted the 2s race in a comment and routed VoIP out viaspawn, but didn't address the underlying foot-gun.This PR makes the cancel conditional — only fires when
SERVER.SELECT_REQUESTactually wins the race. The 2sdelaycontinues to bound how long the watcher listens for a workspace switch; it no longer doubles as a deadline onhandleLoginSuccess.Issue(s)
How to test or reproduce
getPermissions+getEnterpriseModulestogether take >2s on first call (slow network, cold server, or large permission set; you can also pin this locally by addingyield delay(2500)tofetchPermissionsondevelop).To verify the workspace-switch guard still works, dispatch
SERVER.SELECT_REQUESTwhilehandleLoginSuccessis in flight — the saga should still be cancelled.Screenshots
n/a — saga-level fix.
Types of changes
Checklist
app/sagas/has no unit-test harness today; tracked separately as Add unit-test coverage for app/sagas/ #7341.Further comments
Alternative considered: change
call(fetchPermissions)/call(fetchEnterpriseModules)tofork(as suggested in the issue thread). That would also unblock navigation, but leaves the unconditional cancel in place — any future awaited step inhandleLoginSuccesswould silently reintroduce the bug. Fixing the cancel itself addresses the root cause.Summary by CodeRabbit