Repository navigation
fix: make the 10-minute back-off after a failed setup actually apply [ENG-7265] - #93
mattinannt wants to merge 2 commits into
Conversation
…indow [ENG-7265] shouldReturnEarlyForErrorState skipped setup once the error state had expired and retried while it was still active. Invert the check, and make isNowExpired read the ISO strings that dates become after AsyncStorage, so the fixed check cannot skip forever on a reloaded config. The error-state tests now run the real isNowExpired instead of a mock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011A96cuRpyd6PjGE9yABjux
…f applies [ENG-7265]
handleErrorOnFirstSetup stores only `{ status }`. loadFromStorage read
`workspace.expiresAt` unguarded, threw, and dropped the config, so setup never
saw the error state and retried on every call. Guard the workspace read and
add a round-trip test.
Review follow-ups: reset the isNowExpired mock after the back-off tests, give
isNowExpired its own section in utils.test.ts, and assert the result of the
continue-setup case.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011A96cuRpyd6PjGE9yABjux
|
|
No actionable comments were generated in the recent review. WalkthroughExpiration checks now accept Merge Risk:
|



Fixes ENG-7265
What & why
When the first setup fails, the SDK stores an error state that should block setup for 10 minutes. That back-off never worked, for three reasons. This PR fixes all three.
shouldReturnEarlyForErrorStateskipped setup after the error state expired and retried while it was still active. It now skips only while!isNowExpired(expiresAt).isNowExpiredcould not read stored dates. Config goes throughJSON.stringify/JSON.parsein AsyncStorage, soexpiresAtcomes back as an ISO string.new Date() >= "2026-…"compares a number withNaNand is alwaysfalse. With fix 1 alone, a reloaded error state would block setup forever.isNowExpirednow normalises withnew Date(x).getTime().handleErrorOnFirstSetupstores only{ status }, with no workspace.loadFromStoragereadparsedConfig.workspace.expiresAtunguarded, threw a TypeError, and dropped the whole config. Setup therefore never saw the error state. It now readsworkspace?.expiresAt.Because of 3, the ticket's "never sets up again after 10 minutes" could not actually happen in a running app. What did happen was the other symptom: setup retried on every call and there was no back-off. After this PR, the back-off applies for 10 minutes, and then setup runs again.
Alternative rejected: for 2, I considered converting dates back to
Dateobjects insideloadFromStorage. Every date field in the config would then need its own reviver. Normalising in the one helper that compares dates is smaller, and it covers every caller.Side effect of fix 2 (same root cause, intended):
syncUserStateIfExpired(setup.ts:98) also calledisNowExpiredon reloaded string dates, so a user state stored before an app restart was treated as fresh forever. After 30 minutes it now re-syncs, as the code intends.setup.ts:57(workspace) is mostly covered already, becauseloadFromStoragerejects an expired workspace config.Seams tested:
setup()(public),RNConfig.loadFromStorage(),isNowExpired().pnpm api:checkpasses), and reverting it is clean.isSetupbefore readingconfig.workspace, so the workspace-less error config stays in memory only while setup has not run.Tests (red on
main, green here)mainsetup.test.ts› error state back-off › skips setup while not expired (Date, ISO string)setup.test.ts› skips inside the window and continues after it (fake timers, 09:59 / 10:00)setup.test.ts› continues setup once expired (Date)utils.test.ts›isNowExpiredreads an ISO stringfalsefor a past dateconfig.test.ts›loadFromStoragereads back the error state a failed first setup writeserrThe old error-state tests mocked
isNowExpiredand so pinned the inverted behaviour. The new tests run the real function, and the mock is reset after the block.Commands run
pnpm lint✅ ·pnpm format:check✅ ·pnpm check-types✅pnpm test✅ 231/231 ·pnpm test:coverage✅ ·pnpm test:scripts✅pnpm build✅ ·pnpm package-check✅ ·pnpm api:check✅ (no API change)End to end
A container has no device or emulator. The evidence is the unit tests above plus the
e2egolden-journey run on this PR.Open gaps
TConfig, as it was before this PR. Tightening that type is left out of this change.Generated by Claude Code