feat(fs): implement mkdtempDisposable and mkdtempDisposableSync#22068
Closed
feat(fs): implement mkdtempDisposable and mkdtempDisposableSync#22068
Conversation
Implements Node.js-compatible disposable temporary directory functions: - fs.mkdtempDisposableSync() - synchronous version with Symbol.dispose - fs.mkdtempDisposable() - callback version with Symbol.asyncDispose - fs/promises.mkdtempDisposable() - promise version with Symbol.asyncDispose These functions create temporary directories that can be automatically cleaned up using JavaScript's disposable syntax (using/await using). The returned objects include: - path: string - the created directory path - remove: (async) function - manual cleanup method - Symbol.dispose/Symbol.asyncDispose - automatic disposal Matches Node.js implementation from nodejs/node#58516. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Collaborator
Author
|
Updated 11:21 PM PT - Aug 22nd, 2025
❌ Your commit
🧪 To try this PR locally: bunx bun-pr 22068That installs a local version of the PR into your bun-22068 --bun |
Add mkdtempDisposableSync and mkdtempDisposable to the supported APIs list in test-permission-fs-supported.js to prevent test failures. Also removed duplicate mkdtemp entry. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
|
Closing this PR because it has been inactive for more than 90 days. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements Node.js-compatible disposable temporary directory functions for better resource management:
fs.mkdtempDisposableSync()- synchronous version withSymbol.disposefs.mkdtempDisposable()- callback version withSymbol.asyncDisposefs/promises.mkdtempDisposable()- promise version withSymbol.asyncDisposeThese functions create temporary directories that can be automatically cleaned up using JavaScript's disposable syntax (
using/await using).API
All functions return objects with:
path: string- the created directory pathremove(): (Promise<void> | void)- manual cleanup methodSymbol.dispose/Symbol.asyncDispose- automatic disposal supportUsage Examples
Implementation Details
rmSync/rmwithrecursive: true, force: truefor cleanupprocess.chdir()changesTest plan
Symbol.disposeandSymbol.asyncDisposeworksprocess.chdir()changes🤖 Generated with Claude Code