Repository navigation
fix(lockfile): wait for stream close before returning - #12408
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthrough
ChangesLockfile read stream teardown fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by QodoFix lockfile YAML streaming to await stream close on early exit (Windows EPERM) WalkthroughsDescription• Await ReadStream close when exiting early from env-lockfile prefix detection. • Prevent Windows EPERM by releasing file handles before lockfile rewrites/renames. • Add regression test and patch changeset for pnpm + @pnpm/lockfile.fs. Diagramgraph TD
A["Lockfile read/write callers"] --> B["streamReadFirstYamlDocument()"] --> C["closeStream()"] --> D["node:fs ReadStream"] --> E[("Filesystem")]
A --> F["write-file-atomic rename/replace"] --> E
High-Level AssessmentThe following are alternative approaches to this PR: 1. Use stream/promises.finished() to await shutdown
2. Switch to fs.open + incremental reads (no ReadStream)
Recommendation: The current approach (explicitly destroying the ReadStream and awaiting its close event on all early-return/error paths) is a good minimal fix for the Windows EPERM repro while preserving the streaming/early-stop optimization. Consider stream/promises.finished() only if you want a more standard abstraction, but the existing closeStream() helper is straightforward and targeted. File ChangesBug fix (1)
Tests (1)
Other (1)
|
Summary
streamReadFirstYamlDocument()returns@pnpm/lockfile.fsandpnpmFixes the Windows
EPERMrepro from https://github.com/pnpm/pnpm/actions/runs/27505503206/job/81298623383.Tests
pnpm --filter @pnpm/lockfile.fs testPNPM_REGISTRY_MOCK_PORT=7769 NODE_OPTIONS="$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169" pnpm exec jest test/install/dedupe.ts -t "uses the lockfile written by pacquet for post-install checks"fix-win-testsWritten by an agent (Codex, GPT-5).
Summary by CodeRabbit