mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-07-18 08:54:25 -05:00
[PR #1907] [CLOSED] fix(staffml): track and clear toast auto-dismiss timers #32176
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/harvard-edge/cs249r_book/pull/1907
Author: @farhan523
Created: 6/26/2026
Status: ❌ Closed
Base:
dev← Head:fix/staffml-toast-timer-leak📝 Commits (1)
aa682c9fix(staffml): track and clear toast auto-dismiss timers📊 Changes
2 files changed (+101 additions, -4 deletions)
View changed files
➕
interviews/staffml/src/__tests__/toast-timer-cleanup.test.tsx(+77 -0)📝
interviews/staffml/src/components/Toast.tsx(+24 -4)📄 Description
Problem
Each toast schedules a 4s
setTimeoutto auto-dismiss itself, but the timer handle was discarded:So the timer was never cleared. If
ToastProviderunmounts within 4s of a toast (route teardown, fast-refresh, test cleanup) the timer still firessetToastson a dead tree, and a manual dismiss leaves the timer running to a wasted no-op tick.Fix
useRef<Map<id, timeout>>.dismiss().No user-visible behavior change.
Test
Adds
toast-timer-cleanup.test.tsx(fake timers) asserting the pending timer is cleared on unmount and on manual dismiss, and that flushing timers afterward doesn't throw.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.