Repository navigation
fix(provider-core): provider refreshes no longer kill in-flight npm version checks - #42687
juliusmarminge wants to merge 2 commits into
Conversation
…mid-download Reproduces #42676: a provider refresh interrupts the in-flight npm version lookup, killing `npm view` (which leaves a partial packument in npm's cache tmp dir) and starting a new download on the next refresh. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ersion checks Every provider refresh interrupted the snapshot enrichment, and that interrupt reached the latest-version lookup itself. A killed `npm view` leaves its partial packument in npm's cache tmp dir, and the next refresh started the download over, so repeated refreshes filled the disk. ProviderLatestVersions now runs each lookup in its own fiber in the service's scope. Interrupting a caller stops only that caller's wait; the lookup finishes, its result is cached, and later callers share it. Fixes #42676 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosAll 64 scenario measurements match All 64 scenario measurements
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Every provider refresh (from a desktop or phone client, for example) interrupted the running check for the provider's latest version. For npm-installed providers like Codex, that killed
npm viewpartway through downloading ~20 MB of package metadata. npm left the partial file in~/.npm/_cacache/tmp, and the next refresh started the download over, so the files piled up until the disk filled. NowProviderLatestVersionsruns each lookup in the service's own scope: interrupting a caller stops only its wait, the lookup finishes once, and its result is cached for later refreshes.Fixes #42676
Reproduction on main
Commit 024da4f (origin/main). Linux, npm 11.19.1, Codex 0.172.0 installed globally with npm. (1) A local HTTP registry served the real @openai/codex packument (19,956,129 bytes) at about 400 KB/s, so a full download takes more than the 10 s probe timeout. (2) Started
node apps/server/src/bin.ts serve --base-dir <scratch> --port 48790with T3CODE_DEV_SEED=0, npm_config_cache= and npm_config_registry=. At startup the Codex npm version probe (npm view --global --json @openai/codex@latest version) timed out after 10 s and left one 3.68 MB partial packument in /_cacache/tmp. With no client connected, no further probes ran over 3.5 minutes. (3) Issued a bearer session witht3 auth session issueand called theserver.refreshProvidersRPC over the WebSocket 20 times, 3 s apart, as client refreshes do. The registry saw 20 new @openai/codex downloads and _cacache/tmp went from 1 to 21 files (28 MB): each refresh killed the previous probe mid-download and left a file of about 1.1 MB.head -c 300of a leaked file shows "name":"@openai/codex". Before that, at the npm level,timeout 10 npm view ...against the same slow registry left a 3.9 MB temp file. (4) A unit test in packages/provider-core/src/server/maintenanceResolver.test.ts interrupts an in-flight native-install latest-version check (as a refresh does) and checks again. It fails on main with { spawns: 2, killedMidDownload: 1 } where { spawns: 1, killedMidDownload: 0 } is expected.Evidence
Being captured: before and after in the real app. This section is filled in before the pull request can merge.
Tests
vp test run src/server/ProviderLatestVersions.test.ts src/server/maintenanceResolver.test.ts(packages/provider-core): 131 passed; without the source change the repro test fails as the issue describesvp test run src/provider/ProviderRegistry.test.ts src/provider/Drivers/CodexDriver.test.ts src/provider/Drivers/ClaudeMaintenance.test.ts(apps/server): 136 passedvp run typecheck(packages/provider-core): no errorsvp run check:changed: format, lint, knip, typecheck (27 packages) and tests all passNot in this change
npm viewwhen the 10 s timeout hits, which can leave a partial packument on a registry that is slow on every request; changing the timeout or cleaning npm's tmp dir is a separate change.freshlookup or an invalidation while a lookup is running starts a second lookup next to the retired one, as before.Who did the work
Run by the t3code factory in T3 Code.