Skip to content

Commit 0c51a49

Browse files
JohnMcLearclaude
andcommitted
test(ci): schedule a mid-test snapshot 150ms after every beforeEach
Run 26401801404 (PR #7841 after merging develop) captured the dying test's beforeEach node-report — be-0258, written 75ms after socketio.ts > "Pad-wide settings creator gate different browsers" entered — but no further state. The kill landed 321ms into the test body, between 1 Hz heartbeat ticks, and the 100ms boundary throttle prevented further beforeEach writes inside the same test. The report we have shows only the listening server socket; the connections that the test body creates (and that presumably precede the kill) never get snapshotted. Schedule an unref'd setTimeout from beforeEach that fires 150ms after the test entered. If it's still the running test at fire time (i.e. slow enough that the death window applies), capture a node-report from INSIDE the test body — the moment when the real TCP / socket.io activity is in flight. Fast tests (<150ms) skip the write because afterEach has already cleared currentTest by the time the timer fires. Result on the next reproduction of the death pattern: - be-NNNN report at +75ms (beforeEach, body not yet started) - mt-MMMM report at +150ms (mid-test, body in flight, before kill at +320ms) - kill, no further reports Cost: only slow tests (>150ms) generate an mt report, so the artifact size growth is bounded by the count of tests that take longer than 150ms — typically a small minority. Locally verified against a 3-test probe: 2 fast tests skipped, 1 300ms test produced the expected mt-NNNN snapshot. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 98dbba4 commit 0c51a49

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/tests/backend/diagnostics.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,24 @@ export const mochaHooks = {
204204
// boundary writes for any test whose neighbour fired ≥100 ms ago,
205205
// including the socketio tests in the dying-test pattern.
206206
tryWriteReport('be', 100);
207+
// Mid-test snapshot. Run 26401801404 captured the dying test's
208+
// beforeEach write but no further state — the kill landed 321 ms
209+
// into the test body, between the 1 Hz heartbeat ticks, and the
210+
// 100 ms boundary-throttle prevented additional beforeEach writes
211+
// inside a single test. Schedule an unref'd setTimeout that fires
212+
// 150 ms after the test entered: if it's still the running test
213+
// at that point (i.e. slow enough that the death window applies),
214+
// capture a snapshot from INSIDE the test body — where the TCP
215+
// traffic and socket.io activity that precedes the kill happens.
216+
// Fast tests (<150 ms) skip the write because currentTest will
217+
// have already been cleared in afterEach.
218+
const enteredTest = currentTest;
219+
const midSnapshot = setTimeout(() => {
220+
if (currentTest === enteredTest) {
221+
tryWriteReport('mt', 0);
222+
}
223+
}, 150);
224+
midSnapshot.unref();
207225
}
208226
},
209227
afterEach(this: any) {

0 commit comments

Comments
 (0)