Repository navigation
fix(portal): chunk expiry timers beyond 32-bit setTimeout limit - #1971
Merged
Merged
Conversation
callumalpass
marked this pull request as ready for review
November 26, 2026 22:12
callumalpass
enabled auto-merge
November 26, 2026 22:12
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.
Cause
useRequestExpiryinapps/portal/src/authorization-review.tsxand the pending-authorization expiry effect inapps/portal/src/ConnectApp.tsxpassedMath.max(0, Date.parse(expiresAt) - Date.now())directly towindow.setTimeout.Browser
setTimeoutdelays use a signed 32-bit integer (2^31 - 1ms, ~24.85 days). When a deadline is further in the future (such as the2099-08-01T00:00:00.000Zfixture inscripts/browser-accessibility.test.mjs), Chromium truncates the delay modulo2^32to a signed 32-bit integer (ToInt32). Once(Date.parse("2099-08-01T00:00:00.000Z") - Date.now())wrapped across a2^32boundary at2026-11-26T17:11:04Z, the truncated value became negative, which Chromium clamps to0ms.As a result:
useRequestExpiryfiredonExpire()immediately on the next tick, unmounting<RequestIdentity>and its app icon right after initial render and replacing it with the expired outcome — causingauditPortalColdStartAuthorization(scripts/browser-accessibility.test.mjs:720) to time out waiting for.request-identity-mark img[src="https://journal.example/icon.png"].ConnectApp's pending-authorization expiry timer had the same overflow, triggering an immediate re-render loop for far-future expiries.Fix
scheduleAtDeadlineinapps/portal/src/portal-model.ts, which reschedules in chunks capped atMAX_TIMEOUT_MS(2_147_483_647ms), ignores non-finite timestamps, and cleanly cancels the active timer on cleanup.scheduleAtDeadlinein bothuseRequestExpiry(apps/portal/src/authorization-review.tsx) andConnectApp(apps/portal/src/ConnectApp.tsx).apps/portal/src/authorization-return.test.tsx.CI coverage note
In
.github/workflows/server-ci.yml,pnpm test:accessibilityis gated onneeds.classify.outputs.run_full == 'true'. Onpull_requestevents,run_fullis onlytruewhen native paths change (scripts/ci/server-test-plan.mjs) or theci:fulllabel is applied, so this check does not run on ordinary non-native PR heads — it runs inmerge_group(and onpushtomainwhen no matchingmerge_grouprun succeeded).Verification
pnpm --filter @mdbase/connect-portal typecheckpnpm --filter @mdbase/connect-portal testpnpm test:accessibilitypnpm ci:local