Skip to content

fs: add support to Dir for explicit resource management #58206

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aduh95
Copy link
Contributor

@aduh95 aduh95 commented May 7, 2025

No description provided.

@aduh95 aduh95 added the semver-minor PRs that contain new features and should be released in the next minor version. label May 7, 2025
@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels May 7, 2025
Copy link

codecov bot commented May 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.13%. Comparing base (4bfcad1) to head (c7fa030).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #58206      +/-   ##
==========================================
- Coverage   90.14%   90.13%   -0.02%     
==========================================
  Files         630      629       -1     
  Lines      186784   186644     -140     
  Branches    36653    36627      -26     
==========================================
- Hits       168377   168225     -152     
- Misses      11205    11212       +7     
- Partials     7202     7207       +5     
Files with missing lines Coverage Δ
lib/internal/fs/dir.js 94.44% <100.00%> (-0.62%) ⬇️

... and 28 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aduh95 aduh95 added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 7, 2025
@nodejs-github-bot
Copy link
Collaborator

Comment on lines +303 to +318
ObjectDefineProperties(Dir.prototype, { __proto__: null,
[SymbolDispose]: {
__proto__: null,
...nonEnumerableDescriptor,
value: Dir.prototype.closeSync,
},
[SymbolAsyncDispose]: {
__proto__: null,
...nonEnumerableDescriptor,
value: Dir.prototype.close,
},
[SymbolAsyncIterator]: {
__proto__: null,
...nonEnumerableDescriptor,
value: Dir.prototype.entries,
} });
Copy link
Member

Choose a reason for hiding this comment

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

Nit: we don't need __proto__: null in the parent object because Object.defineProperties uses only own properties.

Suggested change
ObjectDefineProperties(Dir.prototype, { __proto__: null,
[SymbolDispose]: {
__proto__: null,
...nonEnumerableDescriptor,
value: Dir.prototype.closeSync,
},
[SymbolAsyncDispose]: {
__proto__: null,
...nonEnumerableDescriptor,
value: Dir.prototype.close,
},
[SymbolAsyncIterator]: {
__proto__: null,
...nonEnumerableDescriptor,
value: Dir.prototype.entries,
} });
ObjectDefineProperties(Dir.prototype, {
[SymbolDispose]: {
__proto__: null,
...nonEnumerableDescriptor,
value: Dir.prototype.closeSync,
},
[SymbolAsyncDispose]: {
__proto__: null,
...nonEnumerableDescriptor,
value: Dir.prototype.close,
},
[SymbolAsyncIterator]: {
__proto__: null,
...nonEnumerableDescriptor,
value: Dir.prototype.entries,
},
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants