-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add mkdtempDisposable() and mkdtempDisposableSync() #24500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Implements fs.mkdtempDisposable() in node:fs/promises and fs.mkdtempDisposableSync() in node:fs. These functions create temporary directories that automatically clean themselves up when disposed using the `await using` and `using` keywords respectively. The returned object has a `path` property containing the created directory path, a `remove()` method for manual cleanup, and implements Symbol.asyncDispose (async) or Symbol.dispose (sync) for automatic cleanup. Tests: - test/js/node/test/parallel/test-fs-promises-mkdtempDisposable.js ✅ - test/js/node/test/parallel/test-fs-mkdtempDisposableSync.js ✅ Fixes #24499 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
0bedabf to
5eb0878
Compare
|
Warning Rate limit exceeded@robobun has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 6 minutes and 57 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (4)
WalkthroughAdds Changes
Pre-merge checks✅ Passed checks (4 passed)
Comment |
Summary
Adds support for
fs.mkdtempDisposable()innode:fs/promisesandfs.mkdtempDisposableSync()innode:fs.These functions create temporary directories that automatically clean themselves up when disposed using the
await usingandusingkeywords respectively.Implementation details
mkdtempDisposable(): Returns a promise that resolves to a disposable object with:
path: The created temporary directory pathremove(): Async function to manually remove the directory[Symbol.asyncDispose](): Automatic cleanup forawait usingmkdtempDisposableSync(): Returns a disposable object with:
path: The created temporary directory pathremove(): Sync function to manually remove the directory[Symbol.dispose](): Automatic cleanup forusingBoth functions stash the full path at creation time to handle
process.chdir()correctly, and recursively remove directory contents on disposal.Test plan
Passing all upstream Node.js tests:
✅
test/js/node/test/parallel/test-fs-promises-mkdtempDisposable.js✅
test/js/node/test/parallel/test-fs-mkdtempDisposableSync.jsTests cover:
await usingandusingremove()calls (both sync and async)Fixes #24499
🤖 Generated with Claude Code