You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(chat): ChatInterface's init keeps running after unmount, so a slow-init test crashes a later test's fallback #16274
components/__tests__/ChatInterface.test.ts:307, "shows loading state while fetching chat history", mocks initializeChatInterface with a 5 s delay (:310). It asserts synchronously and ends, and nothing awaits or unmounts that init.
components/chat/ChatInterface.vue:1054-1056 races the init against a 10 s setTimeout. onUnmounted (:1156) doesn't cancel it. The timer also isn't cleared when the init wins the race.
The timeout fires during a later test. The catch block then runs the fallback controller.loadChatSessions().catch(...) (:1102).
This isn't only a test problem. An init that outlives its component still runs the fallback and writes to the chat store after unmount. On every successful mount, the 10 s timer is also left pending.
Acceptance criteria
ChatInterface.vue clears the init timeout whether the init wins or loses the race.
Once the component has unmounted, nothing after an await in the init runs. A test unmounts mid-init and asserts the fallback is never called.
A run of ChatInterface.test.ts logs no Chat initialization failed.
Folded into #16253's PR (coordinator's call): it touches the same component and the same init path, so it goes through one lifecycle review. That PR will close this issue against the ACs above.
ChatInterface.test.tspasses, 23/23. Each run also logs this error twice:It happens on base 65609f9, and also on a branch that carries #16265. The test stays green, so nothing surfaces it.
Cause (line numbers from base 65609f9)
components/__tests__/ChatInterface.test.ts:307, "shows loading state while fetching chat history", mocksinitializeChatInterfacewith a 5 s delay (:310). It asserts synchronously and ends, and nothing awaits or unmounts that init.components/chat/ChatInterface.vue:1054-1056races the init against a 10 ssetTimeout.onUnmounted(:1156) doesn't cancel it. The timer also isn't cleared when the init wins the race.controller.loadChatSessions().catch(...)(:1102).mockReset: true(vitest.config.ts:75) has stripped:95'svi.fn().mockResolvedValue(undefined), so the call returnsundefinedand.catchthrows. This is the class of bug the warning atvitest.config.ts:71(Enhancement: document vitest mockReset interaction with vi.mock factories #3070) describes.Production impact
This isn't only a test problem. An init that outlives its component still runs the fallback and writes to the chat store after unmount. On every successful mount, the 10 s timer is also left pending.
Acceptance criteria
ChatInterface.vueclears the init timeout whether the init wins or loses the race.awaitin the init runs. A test unmounts mid-init and asserts the fallback is never called.ChatInterface.test.tslogs noChat initialization failed.Found while verifying #16253.