Skip to content

fix(toast): a toast's auto-remove timer no longer outlives its provider - #193

Merged
ShuhaoZQGG merged 1 commit into
devfrom
fix/toast-timer-after-unmount
Dec 3, 2026
Merged

ShuhaoZQGG merged 1 commit into
devfrom
fix/toast-timer-after-unmount

Conversation

@ShuhaoZQGG

Copy link
Copy Markdown
Contributor

No issue: found in CI after #192 merged.

Why

The push run of 7538e48 on dev failed with ReferenceError: window is not defined although all 3,422 tests passed (run); the pull request run of the same commit passed. The error came from ToastContext.jsx:26, reached from AgendaTab.test.jsx: a toast's auto-remove timer fired after the test page had been torn down. It is a race, so it can fail any run, including the release PR's (#191).

What changes

showToast started a setTimeout that nothing ever cleared. In both apps' ToastProvider:

  • pending auto-remove timers are kept in a ref and cleared when the provider unmounts;
  • a showToast that arrives after the provider has gone shows nothing and starts no timer.

Nothing changes while the provider is mounted: a toast shows and leaves as before.

Security

None.

Production impact

No flag. No visible change. In the apps the provider lives as long as the page, so this only matters when it unmounts.

Testing

  • npm test: 168 files, 3,426 passed, no unhandled errors
  • npm run test:e2e: 264 passed, 1 skipped
  • npm run test:specs: 18 specs valid
  • The four new tests fail on the old providers ("expected 2 to be 0": timers left behind) and pass with the fix.
  • Oracle: none (not a factory issue)

Evidence (real Zoom client)

None needed: no Zoom-only surface, and no Zoom-client spec covers ToastContext.jsx.

Not verified

The original failure is a race and was not reproduced as such; the new tests check its cause (a timer left after unmount) directly.

Look here first

apps/zoom-app/src/context/ToastContext.jsx (the web copy is the same change).

showToast started a timer and nothing ever cleared it. In a test the timer
could fire after the page was torn down and set state with no window: the
push run of 7538e48 failed on "ReferenceError: window is not defined"
(from AgendaTab.test.jsx) with all 3,422 tests passing, while the pull
request run of the same commit passed.

Both apps' providers now clear their pending timers when they unmount, and a
showToast that arrives after that shows nothing and starts no timer.
@ShuhaoZQGG ShuhaoZQGG mentioned this pull request Dec 3, 2026
@ShuhaoZQGG
ShuhaoZQGG marked this pull request as ready for review December 3, 2026 19:12
@ShuhaoZQGG
ShuhaoZQGG merged commit ffe8224 into dev Dec 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant