Skip to content

fix(provider-core): provider refreshes no longer kill in-flight npm version checks - #42687

Open
juliusmarminge wants to merge 2 commits into
mainfrom
factory/issue-42676
Open

juliusmarminge wants to merge 2 commits into
mainfrom
factory/issue-42676

Conversation

@juliusmarminge

Copy link
Copy Markdown
Member

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 view partway 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. Now ProviderLatestVersions runs 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 48790 with 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 with t3 auth session issue and called the server.refreshProviders RPC 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 300 of 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 describes
  • vp test run src/provider/ProviderRegistry.test.ts src/provider/Drivers/CodexDriver.test.ts src/provider/Drivers/ClaudeMaintenance.test.ts (apps/server): 136 passed
  • vp run typecheck (packages/provider-core): no errors
  • vp run check:changed: format, lint, knip, typecheck (27 packages) and tests all pass

Not in this change

  • runProbe still kills npm view when 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.
  • A fresh lookup or an invalidation while a lookup is running starts a second lookup next to the retired one, as before.

Who did the work

  • Written by Claude Opus 5.5, in Claude Code
  • Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
  • Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5

Run by the t3code factory in T3 Code.

juliusmarminge and others added 2 commits November 25, 2026 07:44
…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>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅
Claude Live turn messages 1 1 0 (0.0%) 8 ✅

Other scenarios

All 64 scenario measurements match main.

All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling
Codex short turn resume WebSocket decoded 10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅
Codex short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn running, cold open HTTP decoded 281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅
Codex long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Codex long turn running, history page HTTP decoded 92.4 KiB 92.4 KiB 0 B (0.0%) 107.4 KiB ✅
Codex long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Codex long turn finished, cold open HTTP decoded 381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, socket cold open WebSocket decoded 381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, work page HTTP decoded 186.2 KiB 186.2 KiB 0 B (0.0%) 200.2 KiB ✅
Codex long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Codex idle thread resume WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell snapshot HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Codex fleet shell subscribe WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Codex fleet shell resume check rows 0 0 0 0 ✅
Codex stale shell reload HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex stale shell reload rows 27 27 0 (0.0%) 27 ✅
Codex stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Codex stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex stale todo list cold open HTTP decoded 72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅
Codex stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Codex stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅
Claude short turn resume WebSocket decoded 10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅
Claude short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn running, cold open HTTP decoded 283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅
Claude long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Claude long turn running, history page HTTP decoded 93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅
Claude long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Claude long turn finished, cold open HTTP decoded 384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, socket cold open WebSocket decoded 384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, work page HTTP decoded 188.1 KiB 188.1 KiB 0 B (0.0%) 200.2 KiB ✅
Claude long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Claude idle thread resume WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell snapshot HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Claude fleet shell subscribe WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Claude fleet shell resume check rows 0 0 0 0 ✅
Claude stale shell reload HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude stale shell reload rows 27 27 0 (0.0%) 27 ✅
Claude stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Claude stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude stale todo list cold open HTTP decoded 73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅
Claude stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Claude stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅

Baseline: 2fbb071 · PR result: de59a44 · Source CI: success

Scenario and decoded snapshot size

10 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.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes

The latest-version cache now runs lookups in its captured scope, so interrupting a waiting caller does not interrupt the shared lookup. Tests cover cache callers and provider refreshes that reuse an in-flight npm check.

Latest-version lookup lifecycle

Layer / File(s) Summary
Shared lookup lifecycle
packages/provider-core/src/server/ProviderLatestVersions.ts
Cache misses start a lookup fiber in the captured scope. Callers join it interruptibly. Settlement updates the current pending entry, caches successful results, removes failed entries, and completes waiters.
Cache interruption tests
packages/provider-core/src/server/ProviderLatestVersions.test.ts
Tests verify that interrupting the owner leaves the shared lookup available and that a later caller receives the cached result without starting another lookup.
Provider refresh regression test
packages/provider-core/src/server/maintenanceResolver.test.ts
The test interrupts provider enrichment during an npm version check. A second refresh reuses the running process and receives version 1.2.0; the test checks that npm is spawned once and is not killed during the download.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: High

Sequence Diagram(s)

sequenceDiagram
  participant ProviderRefresh
  participant ProviderLatestVersions
  participant NpmProcess
  ProviderRefresh->>ProviderLatestVersions: Request latest version
  ProviderLatestVersions->>NpmProcess: Start version check
  ProviderRefresh->>ProviderLatestVersions: Interrupt enrichment
  ProviderRefresh->>ProviderLatestVersions: Start second enrichment
  NpmProcess->>ProviderLatestVersions: Return version 1.2.0
  ProviderLatestVersions->>ProviderRefresh: Return shared lookup result
Loading

Possibly related PRs

Suggested reviewers: maria-rcks

Merge Risk: Minimal · up to de59a

Provider refresh interruptions no longer kill an in-flight npm version lookup. The lookup can finish and its result is cached, so repeated refreshes stop starting new downloads. No actionable merge-blocking risk remains. The known limitation, that the 10-second probe timeout can still leave a partial packument, is explicitly outside this change.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the change: provider refreshes no longer interrupt in-flight npm version checks. The changeset moves ProviderLatestVersions lookups into the service scope so caller interruption stops …
Description check Passed The description follows the template. It has Problem, Change, Scope, Verification, and Who did the work sections. The Problem and Change sections explain the bug and the fix, with a linked issue (#426…
Linked Issues check Passed [#42676] Requirement: concurrent provider refreshes must not each start a new npm lookup, and interrupted lookups must not leave a partial packument that the next refresh restarts. At head, `ProviderL…
Out of Scope Changes check Passed The diff changes only packages/provider-core/src/server/ProviderLatestVersions.ts and its tests. The source change is the scope move, uninterruptible claim, and settle logic that the PR describes. T…
Full details: Title check

Explanation

The title names the change: provider refreshes no longer interrupt in-flight npm version checks. The changeset moves ProviderLatestVersions lookups into the service scope so caller interruption stops only the caller's wait. The title matches the main change and the linked bug (#42676). It uses the conventional commit form and avoids vague terms. Length (82 characters) is acceptable.

Full details: Description check

Explanation

The description follows the template. It has Problem, Change, Scope, Verification, and Who did the work sections. The Problem and Change sections explain the bug and the fix, with a linked issue (#42676) in Scope. Verification gives focused test commands, results, and a reproduction on main. Two gaps remain. The Evidence section says before/after capture is pending and must be filled in before merge, so the description is incomplete on that point. The template also asks for a note on anything not checked, and the description does not state this for the real-app check. Most required content is present, so the check passes.

Full details: Linked Issues check

Explanation

[#42676] Requirement: concurrent provider refreshes must not each start a new npm lookup, and interrupted lookups must not leave a partial packument that the next refresh restarts. At head, ProviderLatestVersions.cached forks each cache-miss lookup into the service scope (Effect.forkIn(scope)). A caller interrupt stops only its wait (restore(Fiber.join(fiber))). The settle handler caches the result under the existing FOUND/MISSING TTLs. Later callers reuse the cached value or the in-flight Deferred, so one lookup serves many refreshes. The added test in maintenanceResolver.test.ts covers interruption during an in-flight native-install check. Residual gap: runProbe still kills npm view at its 10 s timeout. A slow registry can still leave a partial file in _cacache/tmp by that path. The issue lists registry HTTP queries and throwaway caches as possible fixes, not required approaches. The PR states this limit explicitly. The evidence section is pending, which is not a coding requirement.

Full details: Out of Scope Changes check

Explanation

The diff changes only packages/provider-core/src/server/ProviderLatestVersions.ts and its tests. The source change is the scope move, uninterruptible claim, and settle logic that the PR describes. The test updates in ProviderLatestVersions.test.ts replace assertions about the old interruption behavior with assertions for the new shared-lookup behavior. The maintenanceResolver.test.ts addition is a regression test for the reported bug. No unrelated files or behavior changes appear in the reviewed diff.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 2fbb071 and de59a44.

Files selected for processing: 3

  • packages/provider-core/src/server/ProviderLatestVersions.test.ts
  • packages/provider-core/src/server/ProviderLatestVersions.ts
  • packages/provider-core/src/server/maintenanceResolver.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Killed npm version probes leave partial @openai/codex packuments in ~/.npm/_cacache/tmp until the disk fills

1 participant