Fix infinite loading with auto redirect#26856
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to improve reliability of the UI authentication flow by avoiding a race condition during login (auto-redirect) and adjusting token-expiry timer logic, with an accompanying unit test.
Changes:
- Added a polling-based retry in
onLoginHandlerto wait forauthenticatorRef.currentbefore invoking login. - Updated token-expiry gating logic by switching from
indexOftoincludes(but also changed boolean behavior). - Added a unit test intended to cover the login race condition.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
openmetadata-ui/src/main/resources/ui/src/components/Auth/AuthProviders/AuthProvider.tsx |
Adds polling login invocation and adjusts token-expiry timer start condition. |
openmetadata-ui/src/main/resources/ui/src/components/Auth/AuthProviders/AuthProvider.test.tsx |
Adds a test case intended to validate the new polling/race-condition behavior. |
Code Review ✅ Approved 2 resolved / 2 findingsFixes infinite loading during auto-redirect by addressing race conditions in the login handler and adding polling loop max-retry limits. Two issues resolved: corrected shouldStartExpiry logic and added max-retry safeguards to prevent indefinite polling. ✅ 2 resolved✅ Bug: indexOf-to-includes change inverts shouldStartExpiry logic
✅ Edge Case: Polling loop has no max-retry limit, can poll forever
OptionsDisplay: compact → Showing less information. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
🟡 Playwright Results — all passed (19 flaky)✅ 3420 passed · ❌ 0 failed · 🟡 19 flaky · ⏭️ 216 skipped
🟡 19 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
|
|
Failed to cherry-pick changes to the 1.12.4 branch. |
* Fix login handler to handle race conditions with authenticator ref availability * added tests * address comment (cherry picked from commit 0945626)



This pull request addresses a race condition in the authentication provider's login handler and improves the reliability of the authentication flow. The most significant change is the addition of a polling mechanism to ensure the authenticator reference is available before invoking the login method. Additionally, a minor bug in the logic for determining token expiry handling is fixed. A new test is added to cover the race condition scenario.
Authentication flow improvements:
onLoginHandlerinAuthProvider.tsxto handle cases where the authenticator reference (authenticatorRef.current) may not be available immediately, preventing race conditions during login. The handler now retries every 50ms until the ref is set.Bug fixes:
indexOfwithincludesfor checking the provider type inAuthProvider.tsx.Testing improvements:
AuthProvider.test.tsxto verify thatonLoginHandlercorrectly handles the race condition with the polling mechanism.Describe your changes:
Fixes
I worked on ... because ...
Type of change:
Checklist:
Fixes <issue-number>: <short explanation>