@hienlh/ppm 0.23.31 → 0.23.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/CLAUDE.md +1 -0
- package/assets/skills/ppm/SKILL.md +1 -1
- package/assets/skills/ppm/references/cli-reference.md +4 -4
- package/assets/skills/ppm/references/http-api.md +1 -1
- package/docs/lessons-learned.md +58 -0
- package/package.json +1 -1
- package/scripts/release.sh +5 -0
- package/src/services/bun-runtime-advisory.ts +29 -0
- package/src/services/memory-watchdog.ts +4 -0
- package/src/services/windows-process-tree.ts +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.23.32] - 2026-11-08
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **PPM no longer slowly eats all the memory on Windows.** Bun before 1.3.11 leaks a little memory every time it goes idle, so PPM's background process grew about 400 MB an hour (15 GB after a day and a half); the Windows downloads now ship a fixed Bun, and PPM warns in its log with the fix (`bun upgrade`) when it runs on an affected Bun.
|
|
8
|
+
|
|
3
9
|
## [0.23.31] - 2026-11-06
|
|
4
10
|
|
|
5
11
|
### Fixed
|
package/CLAUDE.md
CHANGED
|
@@ -250,6 +250,7 @@ Related: `configService.save()`/`set()` throw when `load()` has not run, because
|
|
|
250
250
|
- **Playwright's headless shell ignores `--unsafely-treat-insecure-origin-as-secure`**: the default `headless: true` launches `chromium-headless-shell`, where a page on a mapped name (`--host-resolver-rules=MAP ppm-remote.test 127.0.0.1`) stays an insecure origin and loses every API a browser keeps for secure contexts. That is how PPM's chat send was found broken on plain HTTP: it called `crypto.randomUUID`, so a turn never started and the test read as hung. Full Chromium (`channel: "chromium"`, also headless) honours the flag; `ai-tab-tools-e2e.mjs` launches it only for its device-that-is-not-the-host step.
|
|
251
251
|
|
|
252
252
|
- **The chat sidebar's session list read every Codex transcript on disk, synchronously, on every request**: `GET /chat/sessions` asks every provider, and Codex finds a project's sessions by reading the head of each rollout in each account's sessions tree, which holds every project's rollouts (5,262 files / 5.4 GB on the dev host). Done with `readSync` per request, that was 10.9 s of stopped event loop for one project with the files out of the OS cache, and the sidebar lists two or three projects at once — so the server froze 35–90 s at a time, many times a day (`Event loop stalled … cause=blocked`, main thread `waiting/Executive`), taking the usage panel, chat history and health probe down with it. The tell was in the log: nearly every stall had a `/chat/sessions` request whose duration matched the stall to within a second. `codex-rollout-index.ts` now keeps each rollout's header keyed by path and re-reads a file only when its size or mtime moves, reads asynchronously, shares one pass between concurrent callers and reads titles only for the page returned (two projects at once: 135 ms, longest event-loop block ~30 ms). Any new reader of that tree should go through it rather than `readSessionMeta`, which is for single lookups.
|
|
253
|
+
- **Bun before 1.3.11 on Windows leaks every idle helper thread, so PPM must not run on it**: JavaScriptCore's helper threads exit after 10 s idle and come back with the next bit of work, and those releases (measured: 1.2.23, 1.3.9, 1.3.10) never close their handles. Any process on a timer longer than that churns them, and the supervisor reached 7,352 dead `Thread` handles and 15.4 GB of private bytes (484 fully committed 32 MB segments) against a 1.4 GB working set in 37 hours. A script that only sleeps in 15 s gaps leaks ~8 handles a cycle on 1.3.10 and none on 1.3.11–1.4.4. `bun-runtime-advisory.ts` WARNs at start on a runtime measured to leak, and `scripts/release.sh` refuses to build with one, because `bun build --compile` embeds the builder's own runtime in every binary. Releases use 1.3.12: 1.3.13 rejects TLS over an existing socket (the SSH-tunnel database path, `tls-identity-check.test.ts`), and from 1.4.1–1.4.4 `node:child_process` no longer goes through `Bun.spawn`, which blinds the memory monitor's spawn tracker (`memory-watchdog.test.ts`). When timing Bun versions here, run every binary from the same folder: one outside `~/.bun/bin` is Defender-scanned and reads new files 25–50x slower. How to inspect a leaking Windows process without tools: `docs/lessons-learned.md`.
|
|
253
254
|
- **A process with little CPU during a stall was not necessarily starved**: the Windows autostart task once ran at the Task Scheduler's default priority 7, which also means memory priority 2 and I/O priority Low for the supervisor and every child it spawns. The server's main thread then sat in `PageIn` waits for 20-60s on an idle machine (13% CPU) until the health check killed it, while the lag monitor logged `cause=starved`. The task is now priority 5, both processes raise themselves at start (`process-priority.ts`, logged as a `WARN` when it fires), the lag monitor says `cause=blocked` when cores were free, and a failed health probe logs the server's main-thread wait from the supervisor (`process-thread-snapshot.ts`). See `docs/lessons-learned.md`.
|
|
254
255
|
- **The SDK's `getSessionMessages` reads the whole transcript, however little you need from it**: past 5 MB it scans every byte for the last `compact_boundary` (1 MB reads on Bun's pool threads) and then `JSON.parse`s all that follows. The streaming loop's tool_result fallback used to fire on the frames that follow a tool_use inside its own response (`content_block_stop`, `message_delta`, `message_stop`), i.e. on every tool call before the tool had even run, and it yielded each result twice. One 7-day session's 1.47 GB transcript was read back every ~8 s: the server's RSS swung 4.9→12.8 GB, its main thread sat at 96% and requests hit Bun's 10 s timeout. The fallback now waits for a new response (`message_start`, or an assistant frame of another message id). Measured over 3 tool calls on a 401 MB transcript, peak RSS went 1466 MB → 203 MB. Keep it off every per-event path: `getMessages` (a history load) still pays it once per call, `readCompactions` with no window once more. `claude-agent-sdk.test.ts` "tool results" pins both halves of the fallback.
|
|
255
256
|
- **Every Claude CLI must come from `query` in `src/providers/claude-cli-process-group.ts`, never from the SDK's own `query`**: the CLI starts its stdio MCP servers (`npm exec @playwright/mcp`, `slack-mcp-server`) in its own process group, and the SDK spawned the CLI in PPM's, so every CLI and MCP server of every session shared the supervisor's group and a server that outlived its CLI could not be told from a live one. On 2026-10-20 about 30 `npm exec` + node families sat in `ppm.service` hours after their CLI, swap filled, and systemd-oomd killed the unit with every session in it, twice that day. The wrapper spawns the CLI `detached` (a group of its own) and on its exit SIGTERMs the group, then SIGKILLs it 20 s later. Measured with the real CLI: an MCP server that ignores its stdin closing survives the SDK's spawn whether the query is closed or the CLI SIGKILLed, and is gone within 8 s with the wrapper, Playwright's Chrome included. This group teardown never reaches the Bash tool's commands, because the CLI starts each in a session of its own; what can wrap and stop those is leftover tracking, the next entry. A custom spawn has two costs. The SDK no longer reads stderr, so its exit errors lose their `stderr:` tail, though the `stderr` option still gets every line. And a `toEqual` on query options has to ignore `spawnClaudeCodeProcess` the way it ignores `stderr`. Why those servers outlived their CLI in production is still unknown; a `[cli-group] CLI pid=… exited (…) leaving …` warning names each case.
|
|
@@ -73,4 +73,4 @@ This skill covers the `ppm` CLI, its HTTP API, and its config DB. It does **not*
|
|
|
73
73
|
- Third-party extensions (inspect via `ppm ext list`).
|
|
74
74
|
- The Claude Agent SDK internals (separate skill).
|
|
75
75
|
|
|
76
|
-
<!-- Generated for PPM v0.23.
|
|
76
|
+
<!-- Generated for PPM v0.23.32 at build time. Re-run `ppm export skill --install` to refresh. -->
|
|
@@ -843,7 +843,7 @@ Replace a script schedule's state with a JSON file; the schedule must be off
|
|
|
843
843
|
Manage and inspect discovered skills & commands
|
|
844
844
|
|
|
845
845
|
**Options:**
|
|
846
|
-
- `--project <path>` — Project path (default: `"C:\\Users\\PC\\ppm-release-
|
|
846
|
+
- `--project <path>` — Project path (default: `"C:\\Users\\PC\\ppm-release-bun14"`)
|
|
847
847
|
|
|
848
848
|
**Usage:** `ppm skills [options] [command]`
|
|
849
849
|
|
|
@@ -853,7 +853,7 @@ List all discovered skills and commands
|
|
|
853
853
|
|
|
854
854
|
**Options:**
|
|
855
855
|
- `--json` — JSON output
|
|
856
|
-
- `--project <path>` — Project path (default: `"C:\\Users\\PC\\ppm-release-
|
|
856
|
+
- `--project <path>` — Project path (default: `"C:\\Users\\PC\\ppm-release-bun14"`)
|
|
857
857
|
|
|
858
858
|
### `ppm skills search`
|
|
859
859
|
|
|
@@ -861,7 +861,7 @@ Fuzzy search skills and commands
|
|
|
861
861
|
|
|
862
862
|
**Options:**
|
|
863
863
|
- `--json` — JSON output
|
|
864
|
-
- `--project <path>` — Project path (default: `"C:\\Users\\PC\\ppm-release-
|
|
864
|
+
- `--project <path>` — Project path (default: `"C:\\Users\\PC\\ppm-release-bun14"`)
|
|
865
865
|
|
|
866
866
|
**Usage:** `ppm skills search [options] <query>`
|
|
867
867
|
|
|
@@ -871,7 +871,7 @@ Show detailed info for a specific skill
|
|
|
871
871
|
|
|
872
872
|
**Options:**
|
|
873
873
|
- `--json` — JSON output
|
|
874
|
-
- `--project <path>` — Project path (default: `"C:\\Users\\PC\\ppm-release-
|
|
874
|
+
- `--project <path>` — Project path (default: `"C:\\Users\\PC\\ppm-release-bun14"`)
|
|
875
875
|
|
|
876
876
|
**Usage:** `ppm skills info [options] <name>`
|
|
877
877
|
|
|
@@ -500,4 +500,4 @@ _Base URL: `http://localhost:8080` (default; override via `ppm config set port <
|
|
|
500
500
|
- `ws://<host>/ws/terminal` — PTY terminal multiplexer
|
|
501
501
|
- `ws://<host>/ws/extensions` — extension host channel
|
|
502
502
|
|
|
503
|
-
<!-- Generated from src/server/routes/ for PPM v0.23.
|
|
503
|
+
<!-- Generated from src/server/routes/ for PPM v0.23.32 -->
|
package/docs/lessons-learned.md
CHANGED
|
@@ -413,3 +413,61 @@ machine was at 13%. An outside watcher reading the main thread once a second fou
|
|
|
413
413
|
To check a running PPM: `GetProcessInformation(ProcessMemoryPriority)` and
|
|
414
414
|
`NtQueryInformationProcess(ProcessIoPriority = 33)` on its pid; Task Manager shows only the CPU
|
|
415
415
|
class.
|
|
416
|
+
|
|
417
|
+
## Bun 1.3.10 on Windows leaks every idle helper thread (2026-11-08)
|
|
418
|
+
|
|
419
|
+
The supervisor reached 15.4 GB of private bytes against a 1.4 GB working set and a 3 MB JS heap,
|
|
420
|
+
growing about 400 MB an hour, until the machine had 5 GB of commit left out of 53. PPM's code was
|
|
421
|
+
not leaking. Bun 1.3.10 was.
|
|
422
|
+
|
|
423
|
+
What the live process held, read from outside it (no tool needed beyond `bun:ffi`):
|
|
424
|
+
|
|
425
|
+
- 7,352 `Thread` handles while 17 threads were alive. All of them came from one start routine
|
|
426
|
+
inside `bun.exe`, each thread had lived about 10.6 s, and they were created at 3.2 a minute for
|
|
427
|
+
37 hours. That is a JavaScriptCore helper thread that exits after 10 s idle and is recreated on
|
|
428
|
+
the next bit of work, and Bun never closes its handle.
|
|
429
|
+
- 484 fully committed 32 MB allocations, 14.7 GB of the 15.4. The memory monitor's own samples
|
|
430
|
+
grew by exactly 31–33 MB about 370 times and by 0 the rest of the time, so this was allocator
|
|
431
|
+
segments taken and never given back, not a slow drip.
|
|
432
|
+
|
|
433
|
+
A script that does nothing but `await Bun.sleep(15_000)` leaks about 8 thread handles a cycle on
|
|
434
|
+
1.3.10 (7.2 on 1.2.23, 7.9 on 1.3.9) and none on 1.3.11, 1.3.12, 1.3.13, 1.3.14, 1.4.0 or 1.4.4
|
|
435
|
+
(1.3.11 measured side by side with a 1.3.10 control). So every Windows Bun before 1.3.11 has it. Work done back to back leaks nothing on any version, which
|
|
436
|
+
is why spawning PowerShell in a loop never reproduced it. The leak needs the helper thread to go
|
|
437
|
+
idle, exit and come back, which is exactly what any timer longer than 10 s does.
|
|
438
|
+
|
|
439
|
+
Two wrong turns, so nobody repeats them:
|
|
440
|
+
|
|
441
|
+
- The comment on `snapshotServerDescendants` blamed overlapping PowerShell spawns for the 32 MB
|
|
442
|
+
segments. Serialising them did not stop the growth. Every sample of the supervisor did have one
|
|
443
|
+
PowerShell spawn in it, so per-spawn attribution looked conclusive and was confounded with time.
|
|
444
|
+
- A short probe never grew a 32 MB segment, on any version. The thread churn is proven; that the
|
|
445
|
+
segments come from it is the best explanation, not a measurement.
|
|
446
|
+
|
|
447
|
+
What changed: PPM is released with Bun 1.3.12 (the Windows binaries embed the builder's runtime,
|
|
448
|
+
and `scripts/release.sh` now refuses to build with a leaking one), and `bun-runtime-advisory.ts`
|
|
449
|
+
logs a `WARN` at start in every PPM process on a runtime measured to leak, telling the user to run
|
|
450
|
+
`bun upgrade`. Why 1.3.12 and not newer, from the unit suite run against each:
|
|
451
|
+
|
|
452
|
+
- 1.3.13 rejects a TLS connection made over an existing socket with `ERR_TLS_CERT_ALTNAME_INVALID`
|
|
453
|
+
(`tls-identity-check.test.ts`), which is how a database is reached through an SSH tunnel.
|
|
454
|
+
1.3.11, 1.3.12 and 1.4.4 pass.
|
|
455
|
+
- Bun 1.4.x starts at about a quarter of the private bytes, but from somewhere in 1.4.1–1.4.4
|
|
456
|
+
`node:child_process` no longer goes through `Bun.spawn`, so the memory monitor's spawn tracker
|
|
457
|
+
stops seeing the Claude SDK's children (`memory-watchdog.test.ts` catches it). Move to 1.4 only
|
|
458
|
+
together with a fix for that.
|
|
459
|
+
- From 1.3.11 `statSync().mtimeMs` carries sub-millisecond digits on Windows, which a `Date` passed
|
|
460
|
+
to `utimesSync` cannot put back. Only a test depended on that round trip.
|
|
461
|
+
|
|
462
|
+
One trap when comparing Bun versions on this machine: a `bun.exe` anywhere but `~/.bun/bin` reads a
|
|
463
|
+
freshly written file 25–50x slower the first time (855 µs against 31 µs for the same 1.3.10
|
|
464
|
+
binary copied elsewhere), because Defender scans for it and not for the installed one. That made
|
|
465
|
+
newer versions look 2–3x slower on file-heavy tests until the 1.3.10 control was run from the same
|
|
466
|
+
folder.
|
|
467
|
+
|
|
468
|
+
To look at a leaking Windows process: count its handles by object type
|
|
469
|
+
(`NtQuerySystemInformation(SystemExtendedHandleInformation)` filtered by pid, type names from
|
|
470
|
+
`NtQueryObject(ObjectTypesInformation)`), group its committed private memory by allocation base
|
|
471
|
+
(`VirtualQueryEx`), and for `Thread` handles duplicate them and ask `NtQueryInformationThread`
|
|
472
|
+
for create/exit times and the start address. That took minutes; heap snapshots and per-spawn
|
|
473
|
+
attribution had not found it in weeks.
|
package/package.json
CHANGED
package/scripts/release.sh
CHANGED
|
@@ -61,6 +61,11 @@ AHEAD=$(git rev-list --count "origin/main..HEAD")
|
|
|
61
61
|
[ "$BEHIND" = "0" ] || fail "local is $BEHIND commit(s) behind origin/main — pull/rebase first."
|
|
62
62
|
[ "$AHEAD" = "0" ] || fail "local is $AHEAD commit(s) ahead of origin/main — push your source first."
|
|
63
63
|
|
|
64
|
+
# `bun build --compile` embeds the builder's own runtime in every binary, so a
|
|
65
|
+
# Bun known to leak on Windows would ship that leak to every binary install.
|
|
66
|
+
bun -e "const { bunRuntimeAdvisory } = await import('./src/services/bun-runtime-advisory.ts'); process.exit(bunRuntimeAdvisory(Bun.version, 'win32') ? 1 : 0)" || \
|
|
67
|
+
fail "Bun $(bun --version) leaks memory on Windows and would be embedded in the binaries — run \`bun upgrade\` first."
|
|
68
|
+
|
|
64
69
|
echo " ✓ on main · clean · in sync with origin · version $VERSION"
|
|
65
70
|
|
|
66
71
|
# ---------------------------------------------------------------------------
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bun releases with a defect PPM cannot work around in its own code, and what to tell the user.
|
|
3
|
+
*
|
|
4
|
+
* Bun before 1.3.11 on Windows never closes the handle of a JavaScriptCore helper thread. Those
|
|
5
|
+
* threads exit after 10 s idle and come back with the next bit of work, so any PPM process that
|
|
6
|
+
* wakes on a timer (every one of them) recreates and leaks a few every minute. Measured on the
|
|
7
|
+
* supervisor after 37 hours on 1.3.10: 7,352 `Thread` handles with 17 threads alive, and private
|
|
8
|
+
* bytes at 15.4 GB against a 1.4 GB working set — 484 fully committed 32 MB allocator segments,
|
|
9
|
+
* growing ~400 MB an hour until the machine ran out of commit. A script that does nothing but
|
|
10
|
+
* sleep in 15 s gaps leaks 7–8 handles a cycle on 1.2.23, 1.3.9 and 1.3.10, and none on 1.3.11,
|
|
11
|
+
* 1.3.12, 1.3.13, 1.3.14, 1.4.0 or 1.4.4, so the only fix is the runtime: `bun upgrade`.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** First release measured clean, per platform where older ones were measured to leak. */
|
|
15
|
+
const FIXED_IN: Partial<Record<NodeJS.Platform, string>> = {
|
|
16
|
+
win32: "1.3.11",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** A warning for `ppm.log` when this runtime is known to leak, else null. */
|
|
20
|
+
export function bunRuntimeAdvisory(
|
|
21
|
+
version: string = Bun.version,
|
|
22
|
+
platform: NodeJS.Platform = process.platform,
|
|
23
|
+
): string | null {
|
|
24
|
+
const fixedIn = FIXED_IN[platform];
|
|
25
|
+
if (!fixedIn || Bun.semver.order(version, fixedIn) >= 0) return null;
|
|
26
|
+
return `Bun ${version} on Windows leaks a thread handle and allocator memory every time an idle ` +
|
|
27
|
+
`helper thread exits, so this process grows by about 400 MB an hour for as long as it runs. ` +
|
|
28
|
+
`Run \`bun upgrade\` (${fixedIn} and later are fixed), then restart PPM.`;
|
|
29
|
+
}
|
|
@@ -24,6 +24,7 @@ import { readNativeMemory } from "./memory-diagnostics-native.ts";
|
|
|
24
24
|
import { spawnTracker } from "./memory-diagnostics-spawns.ts";
|
|
25
25
|
import { diffRequestCounts, requestTracker } from "./memory-diagnostics-requests.ts";
|
|
26
26
|
import { descendantsOf, readProcessList } from "./process-tree-memory.ts";
|
|
27
|
+
import { bunRuntimeAdvisory } from "./bun-runtime-advisory.ts";
|
|
27
28
|
import { heapStats } from "bun:jsc";
|
|
28
29
|
|
|
29
30
|
const log = createLogger("mem");
|
|
@@ -129,6 +130,9 @@ export function startMemoryWatchdog(role: string, readGauges: () => Record<strin
|
|
|
129
130
|
let lastSummaryPrivateMB: number | undefined;
|
|
130
131
|
let lastRequests = requestTracker.read();
|
|
131
132
|
|
|
133
|
+
const advisory = bunRuntimeAdvisory();
|
|
134
|
+
if (advisory) log.warn(`${role} pid=${process.pid}: ${advisory}`);
|
|
135
|
+
|
|
132
136
|
spawnTracker.onLifecycle = (e) => {
|
|
133
137
|
const who = `${e.label} pid=${e.pid}${e.session ? ` session=${e.session}` : ""}`;
|
|
134
138
|
if (e.event === "start") log.info(`${who} started`);
|
|
@@ -280,11 +280,11 @@ let snapshotInFlight = false;
|
|
|
280
280
|
|
|
281
281
|
export async function snapshotServerDescendants(rootPid: number): Promise<void> {
|
|
282
282
|
if (process.platform !== "win32") return;
|
|
283
|
-
// The supervisor fires this from a timer without awaiting
|
|
284
|
-
//
|
|
285
|
-
//
|
|
286
|
-
//
|
|
287
|
-
//
|
|
283
|
+
// The supervisor fires this from a timer without awaiting, so calls must not
|
|
284
|
+
// overlap: each one spawns a PowerShell. One at a time; a skipped tick is
|
|
285
|
+
// harmless. The supervisor's commit charge kept climbing after this guard went
|
|
286
|
+
// in (15GB committed against 1.4GB resident); that was Bun 1.3.10 leaking idle
|
|
287
|
+
// helper threads, not this call — see bun-runtime-advisory.ts.
|
|
288
288
|
if (snapshotInFlight) return;
|
|
289
289
|
snapshotInFlight = true;
|
|
290
290
|
try {
|