Repository navigation
Commit e905bde
fix(server): record main-thread stacks when memory bursts past 4 GiB (#1719)
## Problem
In the 2026-10-12 burst, the event loop was blocked from the start.
Every timer and log stopped, so the memory watch from #1718 cannot fire in that case.
Signal-based reports wait for the loop too.
## Change
`startStackWatch` in `MemoryWatch.fork.ts`, started by the existing layer:
### Capture
- **Runs on:** a worker thread, off the main loop
- **Trigger:** process RSS past 4 GiB
- **Action:** inspector `Debugger.pause`, 3 times
- **Interval:** 1 s between pauses
### Output
- **Output:** `server-<pid>-<time>.stacks.json`
- **Location:** `logsDir`, mode 0600
- **Released:** with the layer scope
The inspector interrupts running JavaScript, so each pause names the stuck frame.
## Scope and approval
Refs #1717.
The maintainer asked for the root cause; this captures it on the next burst.
No main-thread cost below 4 GiB; the worker only reads RSS once a second.
## Verification
- **Unit test:** 2 of 2 pass
- **Covers:** a 3 s sync loop on the main thread
- **Asserts:** first frame is the stuck function
- **Typecheck:** `apps/server`, exit 0
- **Fork CI:** `vp run fork:ci`, exit 0
- **Not checked:** a live 4 GiB burst; no repro yet
Claude Code, claude-opus-5-5.
## Fork trailers
Squashes:
- 0b7add0 fix(server): record main-thread stacks when memory bursts past 4 GiB (#1719) (#1719)
- 03a61db fixup! fix(server): record main-thread stacks when memory bursts past 4 GiB (#1719) (#1719)
- 75a24fc fix(server): record main-thread stacks when memory bursts past 4 GiB (#1719) (#1719)
- d85d60d fixup! fix(server): record main-thread stacks when memory bursts past 4 GiB (#1719) (#1719)
Fork-Domain: upstream-fixes
Fork-Tier: bugfix
Fork-Upstreamable: yes1 parent afe2734 commit e905bde
2 files changed
Lines changed: 101 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
1 | 6 | | |
2 | 7 | | |
3 | | - | |
| 8 | + | |
4 | 9 | | |
5 | 10 | | |
6 | 11 | | |
| |||
29 | 34 | | |
30 | 35 | | |
31 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
1 | 4 | | |
2 | 5 | | |
3 | 6 | | |
| |||
40 | 43 | | |
41 | 44 | | |
42 | 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 | + | |
| 103 | + | |
| 104 | + | |
43 | 105 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
48 | 110 | | |
49 | 111 | | |
50 | 112 | | |
51 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
52 | 118 | | |
53 | 119 | | |
54 | 120 | | |
| |||
0 commit comments