fix: npmx connector Node.js v22 compatibility#2665
fix: npmx connector Node.js v22 compatibility#2665DDeenis wants to merge 2 commits intonpmx-dev:mainfrom
Conversation
…licit cleanup for Node v22 compatibility
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughSummary by CodeRabbit
Walkthrough
Changes
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@cli/src/npm-client.ts`:
- Around line 625-627: The cleanup in the finally block calls await
rm(tempDirPath, { recursive: true, force: true }) which can mask an earlier
error from the try block; change the finally to capture any earlier error (store
the caught error from the try/catch or wrap the try in a variable like
originalError), then perform the rm inside its own try/catch and if the cleanup
fails, log or attach the cleanup error but rethrow the original error (or throw
the cleanup result only if there was no originalError). Specifically, update the
code around the rm(tempDirPath, ...) call so that rm failures do not overwrite
the original publish/write failure—use a nested try/catch in the finally or
Promise.allSettled and rethrow originalError (or return successful result)
accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2d591085-20d8-4301-833c-0652272d221e
📒 Files selected for processing (1)
cli/src/npm-client.ts
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@ghostdevv okay, this makes more sense. In this case, the issue is that Node 22 users don't get a warning of unsupported engine. Feel free to close this PR in case the downgrade is unwanted. |
🔗 Linked issue
Resolves #2645
🧭 Context
npmx-connectorcurrently crashes for users trying to run it with Node.js 22, which is still in the maintenance and used by many people. This PR fixes the only incompatible function (packageInit).📚 Description
Node v24+ only features used:
mkdtempDisposable- for temp dir creationawait using- to ensure the temp dir cleanupReplaced with compatible versions:
mkdtempDisposable->mkdtempawait using-> Manual disposal withrmFix verified on Node v22
Tradeoffs: if both the function code andrmwill throw, only the error fromrmwould be preserved. Should be possible to fix at a cost of complex cleanup logic, but the situation seems unlikely.