Skip to content

fix(ext/node): add Symbol.dispose and Symbol.asyncDispose to fs.Dir#33000

Merged
bartlomieju merged 2 commits intodenoland:mainfrom
majiayu000:fix/32966-node-fs-dir-disposable
Mar 26, 2026
Merged

fix(ext/node): add Symbol.dispose and Symbol.asyncDispose to fs.Dir#33000
bartlomieju merged 2 commits intodenoland:mainfrom
majiayu000:fix/32966-node-fs-dir-disposable

Conversation

@majiayu000
Copy link
Copy Markdown
Contributor

@majiayu000 majiayu000 commented Mar 25, 2026

Closes #32966

Adds Symbol.dispose and Symbol.asyncDispose to the Dir class in ext/node/polyfills/_fs/_fs_dir.ts, so that using and await using work with fs.Dir objects.

  • [Symbol.dispose]() delegates to closeSync() (no-op in Deno, mirrors Node behavior)
  • [Symbol.asyncDispose]() delegates to close() (returns Promise<void>)

FileHandle already implements [Symbol.asyncDispose] and required no change.


Note: This PR was written with AI assistance (Claude).

@majiayu000 majiayu000 marked this pull request as ready for review March 25, 2026 20:40
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should be a unit test in tests/unit_node/fs

Address review feedback on PR denoland#33000: replace spec test with a unit
test in tests/unit_node/fs_test.ts as requested by @bartlomieju.

Signed-off-by: majiayu000 <1835304752@qq.com>
Copy link
Copy Markdown
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

Thanks

@bartlomieju bartlomieju merged commit 7250271 into denoland:main Mar 26, 2026
114 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

node:fs objects are not disposable

2 participants