Skip to content

test(npm): isolate mock registry faults from inherited cache - #575

Merged
agenteinstinct1-max merged 2 commits into
dev-vibecodedfrom
fix/574-mock-registry-isolation
Oct 24, 2026
Merged

agenteinstinct1-max merged 2 commits into
dev-vibecodedfrom
fix/574-mock-registry-isolation

Conversation

@agenteinstinct1-max

@agenteinstinct1-max agenteinstinct1-max commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Issue for this PR

Closes #574

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Isolate the core mock-registry tests from inherited npm settings. An inherited npm_config_cache overrides their project .npmrc, letting an already-cached tarball bypass the injected HTTP500, broken connection or stall. All three tests then return Success instead of Failure.

The wrapper runs the original 10-test fixture suite in a bounded child with npm/HOME/proxy environment isolated before npm imports. Per-test hooks alone cannot undo @npmcli/agent cached proxy environment. The child uses private empty user/global npmrc files; the host environment is never mutated by the wrapper. Tarball error tests now assert a tarball was requested, and interruption waits for the real tarball request instead of assuming 100ms reaches the stall. A bounded subprocess regression runs the fixture with a hostile inherited registry, npmrc and shared-cache setting. Production npm precedence is unchanged.

How did you verify your code works?

  • Original fixture with npm_config_cache: 7 passed, 3 failed. Removing inherited npm config: 10 passed. Reintroducing only the cache variable reproduces all three failures.
  • Earlier hooks-only focused run: 11 passed, 24 assertions. Updated pre-import isolation: 2 outer tests passed, 3 outer assertions; each requires the original 10-test child suite to pass.
  • Removing the pre-import environment filter makes the hostile child regression fail (7 child failures).
  • Full core through npm exec, which injects npm settings: 1401 passed, 1 Windows-only skip, 0 failed, 3870 assertions in the outer run, plus the original 10-test child suite executed twice (normal and hostile wrapper runs). Parent counts are lower because the 10 original tests moved into an explicitly invoked non-discovered fixture suite, not because assertions were removed.
  • git diff --check passes. Exact-head CI is green; actual Kilo is clean and independent review approved c5e870b.

Proxy review: the old hooks-only head failed with inherited dead HTTP(S)_PROXY. Updated hostile regression includes uppercase/lowercase proxy variables and empty NO_PROXY, while the wrapper removes them before npm import. The Kilo Promise.all pipe deadlock suggestion was independently refuted: both streams drain concurrently and a 32MiB-per-stream stress completed. No cosmetic pipe change was made.

This does not fix or explain #560's historical FETCH_ABORTED/Turbo crash.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

})
const timeout = setTimeout(() => child.kill(), 20_000)
try {
const [code, stdout, stderr] = await Promise.all([

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: Awaiting child.exited while concurrently reading stdout/stderr can deadlock under heavy output

If the child writes more than the OS pipe buffer before the streams are drained, the child blocks on writing and child.exited never resolves until the 20 s kill timer fires, producing a slow failure. Drain stdout/stderr (or read them before awaiting exit) so output cannot back-pressure the child.

@kilo-code-bot

kilo-code-bot Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • packages/core/test/fixture/npm-registry/suite.ts
  • packages/core/test/npm-mock-registry-isolation.test.ts
  • packages/core/test/npm-mock-registry.test.ts
Previous Review Summary (commit 36824e2)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 36824e2)

Status: 1 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/core/test/npm-mock-registry-isolation.test.ts 25 Awaiting child.exited while concurrently reading stdout/stderr can deadlock under heavy output
Files Reviewed (2 files)
  • packages/core/test/npm-mock-registry-isolation.test.ts - 1 issue
  • packages/core/test/npm-mock-registry.test.ts - 0 issues

Fix these issues in Kilo Cloud


Reviewed by free · Input: 27.1K · Output: 3.9K · Cached: 135.7K

@agenteinstinct1-max
agenteinstinct1-max merged commit 3f092ab into dev-vibecoded Oct 24, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant