Repository navigation
fix(dashboard-e2e): Close open connections when a spec stops its own server - #2474
Merged
Merged
Conversation
…server conversation-share.spec.ts starts its own dashboard server and closes it while the page is still open. server.close() waited on the page's keep-alive connections, so the test hung until its 30s timeout. This failed 9 of 20 local runs on main, and 5 of 20 before the review desk merged. With closeAllConnections() it passed 20 of 20. Co-Authored-By: David Cramer <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
1 screenshot change — 1 changed · 0 added · 0 removed Review screenshots in Frameshift
|
dcramer
approved these changes
Oct 31, 2026
dcramer
added a commit
that referenced
this pull request
Nov 16, 2026
In the junior Vitest suite, `Date` now starts each test file and each test 5 s after the start of the current real minute, and then moves forward in real time. This is the offset clock the evals already use. It moves from `junior-evals/src/eval-clock.ts` to `@sentry/junior-testing/clock`, and the evals import it from there. ## Why Recent fixes for nondeterministic tests, grouped by mechanism: | Mechanism | Fix | Suite | Harness default before this PR | | --- | --- | --- | --- | | Wall clock | #3265: a run that crossed a minute boundary left fixture stamps newer than a Turn | junior Vitest | **None.** The test pinned its own clock. | | Wall clock | #2111: model-derived times went stale between recording and replay | evals | Eval clock | | Shared state | #3355: the Redis user cache outlived the Postgres reset | evals | Per-test namespace delete | | Shared state | #1775: module-level mock state leaked between specs | dashboard e2e | Reset in the page fixture | | Shared state | #2474: keep-alive connections blocked server close | dashboard e2e | `closeAllConnections()` | | Timing | #1925, #3316: one-off races | junior Vitest, dashboard e2e | Fixed in each fixture or spec | The only mechanism with no harness default was the wall clock in the junior Vitest suite, so this PR changes only that. ## What the harness guarantees - Each test starts at second 5 of a minute. A test that runs for less than 55 s cannot cross a minute boundary by chance. #3265 is no longer possible, so `versions.test.ts` drops its own pin. - `Date` stays within a minute of real time. Times that JS stamps stay comparable with Postgres `now()`, `defaultNow()` columns, and real servers such as S3, so no test needs an opt-out. A fixed calendar instant would put `Date` weeks away from those clocks. - The clock keeps millisecond steps and real-time speed. Timers and `performance.now()` stay real. Sinon's Date-only fake (`shouldAdvanceTime`) moves in 20 ms steps and does not move during microtask-only work. Timestamps would then tie and make `ORDER BY created_at` flaky, so this PR does not use it. - `vi.useFakeTimers()`, `vi.setSystemTime()`, and `vi.spyOn(Date, "now")` work on top of the clock. - A global `afterEach` calls `vi.useRealTimers()`, so fake timers do not leak into the next test. A test that forgets `vi.useRealTimers()` no longer shows up as a leak in later tests. ## Left out - Shared state and timing: each listed fix already lives in its own harness or was one specific race. The junior Vitest suite already resets Postgres and the state adapter for each integration test, and I found no common leak to guard against. - Calendar-dependent output, such as weekday or month names, still follows the real date. No listed fix came from that. - Existing per-test `vi.setSystemTime` pins still work and stay as they are. <!-- junior-request-attribution:start --> via @dcramer. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3Ae0825347725c723b07a008a8b27a2961 --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3Ae0825347725c723b07a008a8b27a2961) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Ae0825347725c723b07a008a8b27a2961/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]>
This branch was successfully deployed
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.
conversation-share.spec.tsis the only spec that starts its own dashboard server. Itsfinallyblock closes that server while the page is still open.server.close()waits for every open connection to end. The page keeps reusing its keep-alive connections, so the close never finished and the test hit its 30s timeout. That is the "Test timeout of 30000ms exceeded" with no failing step that showed on #2468 and onmain.A Playwright trace confirms it. Every step passed, including the last
toBeVisible. The 15s gap after it was thefinallyblock.The fix calls
server.closeAllConnections()afterserver.close().Local runs (
--repeat-each=10 --retries=0, 20 runs per row):mainwithout the fix: 9 failede215da01a, before the review desk UI merged: 5 failedmainwith the fix: 0 failedThe flake was there before the review desk merged.
The
Failed query ... relation "junior_review_items" does not existnoise in the dashboard e2e logs is a separate issue. A follow-up PR adds mock review item routes for it.via David Cramer.
--
View Session [Sentry]