Repository navigation
Commit ca4ec2a
fix(auth): a hung "Sign in with SSO" request gives the login page back after the 20 s sign-in watchdog (#35737)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoA1ALjVcUcAuAA15MyUocBx)_
Fixes #34861
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 用户能看到什么变化:登录页按“使用 SSO 登录”后若服务器一直不回应,约 20
秒后转圈停止、提示登录超时,邮箱框和按钮恢复可用,可以直接重试;此前会一直转圈直到刷新页面。
- 为什么做:修复单点登录用户在身份提供方接口卡住时被困在登录页的问题,与其他登录按钮已有的 20 秒超时保护对齐。
- 出错会怎样:只影响按邮箱走单点登录的那一步;最坏情况是超时提示出现得过早或不出现,可直接撤回本次改动恢复原样。
- 要你做什么:无
## What changes
- `ui/packages/auth/src/LoginForm.tsx`, `handleSso`: the `POST
/api/v1/auth/sign-in/sso` request now carries an `AbortController`
signal, aborted after `SSO_SIGN_IN_TIMEOUT_MS` (20 000 ms). On that
abort the form shows `SSO_SIGN_IN_TIMEOUT_TEXT` and clears
`ssoSubmitting`, so the SSO button and the SSO email field are usable
again (retry path). The timer is cleared in `finally` on every settle; a
successful answer still navigates to `data.url` and keeps the pending
state through teardown.
- The window and the sentence are the same as the provider buttons'
watchdog (`SIGN_IN_TIMEOUT_MS` / `withTimeout` inside
`signInWithProvider` in `createAuthClient.ts`). They are module
constants in `LoginForm.tsx`, not imported: `createAuthClient.ts` is
outside this card's file surface, and the watchdog there is a local of
`signInWithProvider` with nothing exported to share.
- The body read (`res.json()`) is also under the signal: an abort during
the body read surfaces as the timeout, not as the "No SSO provider"
fallback.
- Changeset: `@object-ui/auth` patch.
## Why
A hung SSO request left the button spinning and the email field disabled
until a reload (reproduced by QA twice under SSO-only mode). The card's
expected behaviour: "after about 20 s the watchdog recovers the button
with an error and a retry path."
## Tests
New top-level `describe` in the shared harness
`ui/packages/auth/src/__tests__/LoginForm.test.tsx` (SSO-only mode, fake
`setTimeout`/`clearTimeout`):
- Pin: the SSO fetch never answers. At 19 999 ms the button and the
email field are still disabled, the request's signal is not aborted and
no alert shows; at 20 000 ms the signal is aborted, the alert reads as a
timeout, and the button and the email field are enabled.
- CONTROL: an answering fetch still sets `window.location.href` to the
IdP URL; after 20 s the signal is not aborted, the button keeps its
pending state, and no alert shows.
<details><summary>Readings at head 171e0ee (after merging origin/main
a3a74f2)</summary>
- `pnpm --dir ui exec vitest run packages/auth/` under the verify lock:
`Test Files 48 passed (48)`, `Tests 493 passed (493)`, VERDICT
command-exit 0.
- `pnpm --filter @object-ui/auth type-check` (`tsc --noEmit && tsc -p
tsconfig.test.json`; the second program includes `src/**/*.test.tsx`):
VERDICT command-exit 0.
- Ablation (at c00af54, the fix committed first; the test imports
`../LoginForm` from source, no dist in the path): `node
scripts/ablation-replace.mjs` replaced the timer body
`controller.abort();` / `SSO_SIGN_IN_TIMEOUT_MS` with a no-op and a 1e9
ms delay (anchor x1 to x0, replacement x0 to x1, blob 990a9ef to
60b77598). Pin RED: `expected false to be true` on `signal.aborted`;
CONTROL green. Restored: blob equals HEAD (990a9ef), `git diff HEAD`
empty.
</details>
## Acceptance notes
- The 20 s value and the timeout sentence now live in two places
(`LoginForm.tsx` module constants and the local inside
`signInWithProvider`). Moving the watchdog into one shared module is a
follow-up for whoever next edits `createAuthClient.ts`; not done here
because that file was outside this card's surface.
- The timeout sentence is not localized, same as the provider buttons'
watchdog sentence (shown via the error's message). No new
`LoginFormLabels` key was added.
- `onError` is not called on the SSO path, as before this change.
## Verification
Read first: `ui/packages/auth/src/LoginForm.tsx` `handleSso` (risk hunk:
the `res.json().catch` rethrow on timeout and the `finally` clearing the
timer, which must not fire after a successful navigation).
Two-minute check: `pnpm --dir ui exec vitest run
packages/auth/src/__tests__/LoginForm.test.tsx -t "aborted after 20 s"`
shows 2 passed.
<details><summary>Local gate readings</summary>
- `node scripts/pm/dispatch-gates.mjs --commands` derived 38 families
for this diff. 37 ran at head 171e0ee, all exit 0. `--ran`
reconciliation: "38 derived famil(ies) accounted for — 38 run, 0
NOT-MEASURED".
- `pnpm --dir ui exec vitest run scripts/` ran once at c00af54 (before
the merge): exit 1, 2 files red of 173
(`date-only-zone-pins-10183.test.ts`, which drives other ui packages'
zone tests, and a closure-budget test that needs a built Console bundle:
"Budgeted chunk `ui-components` is ABSENT from the eager closure").
Neither reads `ui/packages/auth`. Read as an unbuilt-workspace reading,
not a verdict, and left to CI's `Test UI`.
- `node scripts/pm/overlap-check.mjs --branch=HEAD` and `--pr=35575`:
VERDICT clean exit 0.
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [ ] 3. No formatter ran; `pnpm lint` passes. (No formatter ran; `pnpm
lint` is a repo-wide scan left to CI, not run locally.)
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (Not touched.)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L9qibyy9KSA69EGZtjDj9c
Co-authored-by: Claude <noreply@anthropic.com>1 parent 1e692d1 commit ca4ec2a
3 files changed
Lines changed: 100 additions & 4 deletions
File tree
- .changeset
- ui/packages/auth/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
190 | 198 | | |
191 | 199 | | |
192 | 200 | | |
| |||
536 | 544 | | |
537 | 545 | | |
538 | 546 | | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
539 | 556 | | |
540 | 557 | | |
541 | 558 | | |
542 | 559 | | |
543 | 560 | | |
544 | 561 | | |
545 | 562 | | |
| 563 | + | |
546 | 564 | | |
547 | | - | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
548 | 569 | | |
549 | 570 | | |
550 | 571 | | |
| |||
553 | 574 | | |
554 | 575 | | |
555 | 576 | | |
556 | | - | |
| 577 | + | |
557 | 578 | | |
| 579 | + | |
| 580 | + | |
558 | 581 | | |
559 | 582 | | |
560 | 583 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
| 11 | + | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
551 | 551 | | |
552 | 552 | | |
553 | 553 | | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
0 commit comments