Commit b446ad5
fix(pause): remove leaked dispatcher listeners and guard session restore
Every pause() call registered two permanent listeners on the global event
dispatcher (step.after, test.finished) and never removed them. Repeated
pauses — now the normal case because the MCP server drives pause()
programmatically via setPauseHandler/pauseNow — accumulated listeners, fired
finish() multiple times, and ran an unconditional recorder.session.restore('pause')
on every test finish even when no pause session was open, unbalancing the
recorder's session stack (the hang class blocking 4.0).
- Convert the two anonymous listeners into named handlers (onStepAfter,
onTestFinished) and register them through an idempotent helper that removes
any prior registration first, so repeated pause()/pauseNow() keep exactly
one of each. onTestFinished removes both listeners when the test finishes.
- Track an open-pause flag and only restore the 'pause' session when one is
actually open (set on session.start in pauseSession, cleared at all three
restore sites).
- pauseNow now performs the same idempotent registration as pause().
setPauseHandler/pauseNow signatures and resolve semantics are unchanged
(bin/mcp-server.js untouched). 4 regression tests cover idempotent
registration, listener removal on finish, the no-double-restore guard, and the
MCP pauseNow lifecycle; reverting the fix fails the listener tests.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent a70c814 commit b446ad5
2 files changed
Lines changed: 109 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
22 | 51 | | |
23 | 52 | | |
24 | 53 | | |
| |||
28 | 57 | | |
29 | 58 | | |
30 | 59 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 60 | + | |
47 | 61 | | |
48 | 62 | | |
49 | 63 | | |
50 | 64 | | |
51 | 65 | | |
52 | 66 | | |
53 | 67 | | |
| 68 | + | |
54 | 69 | | |
55 | 70 | | |
56 | 71 | | |
57 | 72 | | |
58 | 73 | | |
59 | 74 | | |
| 75 | + | |
60 | 76 | | |
61 | 77 | | |
62 | 78 | | |
| |||
107 | 123 | | |
108 | 124 | | |
109 | 125 | | |
| 126 | + | |
110 | 127 | | |
111 | 128 | | |
112 | 129 | | |
| |||
265 | 282 | | |
266 | 283 | | |
267 | 284 | | |
| 285 | + | |
268 | 286 | | |
269 | 287 | | |
270 | 288 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
3 | 16 | | |
4 | 17 | | |
5 | 18 | | |
| |||
26 | 39 | | |
27 | 40 | | |
28 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
0 commit comments