-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
fs/promises: fix fd resource cleanup #35208
Conversation
Looking at git blame, it looks like d00d81e intentionally removed the |
lib/internal/fs/promises.js
Outdated
@@ -522,7 +522,7 @@ async function lchmod(path, mode) { | |||
throw new ERR_METHOD_NOT_IMPLEMENTED('lchmod()'); | |||
|
|||
const fd = await open(path, O_WRONLY | O_SYMLINK); | |||
return fchmod(fd, mode).finally(fd.close); | |||
return fchmod(fd, mode).finally(fd.close.bind(fd)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fchmod(fd, mode).finally(fd.close.bind(fd)); | |
return fchmod(fd, mode).finally(FunctionPrototypeBind(fd.close, fd)); |
Is there a way we can add a test for this? |
3cf0f4d
to
ae6aea0
Compare
Right, I did see that commit and I understand how it works but it doesn't look Obviously Right to me. But if other people feel it's great idea, then the thing to do is to at least be consistent. I've changed it to remove the |
Commit Queue failed- Loading data for nodejs/node/pull/35208 ✔ Done loading data for nodejs/node/pull/35208 ----------------------------------- PR info ------------------------------------ Title fs/promises: fix fd resource cleanup (#35208) Author Ben Noordhuis (@bnoordhuis) Branch bnoordhuis:fix-fs-promises-fd-close -> nodejs:master Labels fs Commits 1 - fs/promise: remove unnecessary Function#bind() Committers 1 - Ben Noordhuis PR-URL: https://github.com/nodejs/node/pull/35208 Reviewed-By: Colin Ihrig Reviewed-By: Masashi Hirano Reviewed-By: Anna Henningsen ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/35208 Reviewed-By: Colin Ihrig Reviewed-By: Masashi Hirano Reviewed-By: Anna Henningsen -------------------------------------------------------------------------------- ✔ Last GitHub Actions successful ℹ Last Full PR CI on 2020-10-04T09:58:54Z: https://ci.nodejs.org/job/node-test-pull-request/33368/ - Querying data for job/node-test-pull-request/33368/ ✔ Build data downloaded ✔ Last Jenkins CI successful ℹ This PR was created on Tue, 15 Sep 2020 13:02:12 GMT ✔ Approvals: 3 ✔ - Colin Ihrig (@cjihrig) (TSC): https://github.com/nodejs/node/pull/35208#pullrequestreview-489637752 ✔ - Masashi Hirano (@shisama): https://github.com/nodejs/node/pull/35208#pullrequestreview-490204047 ✔ - Anna Henningsen (@addaleax): https://github.com/nodejs/node/pull/35208#pullrequestreview-493011764 -------------------------------------------------------------------------------- ✔ No git cherry-pick in progress ✔ No git am in progress ✔ No git rebase in progress -------------------------------------------------------------------------------- - Bringing origin/master up to date... From https://github.com/nodejs/node * branch master -> FETCH_HEAD ✔ origin/master is now up-to-date - Downloading patch for 35208 From https://github.com/nodejs/node * branch refs/pull/35208/merge -> FETCH_HEAD ✔ Fetched commits as d3969003b564..ae6aea04b839 -------------------------------------------------------------------------------- Auto-merging lib/internal/fs/promises.js warning: inexact rename detection was skipped due to too many files. warning: you may want to set your merge.renamelimit variable to at least 2818 and retry the command. [master 3c2a1e9af5] fs/promise: remove unnecessary Function#bind() Author: Ben Noordhuis Date: Tue Sep 15 18:40:39 2020 +0200 1 file changed, 1 insertion(+), 1 deletion(-) ✔ Patches applied -------------------------------------------------------------------------------- --------------------------------- New Message ---------------------------------- fs/promise: remove unnecessary Function#bind() Commit Queue action: https://github.com/nodejs/node/actions/runs/351509796 |
PR-URL: #35208 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Masashi Hirano <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Landed in f06f3c0 |
PR-URL: #35208 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Masashi Hirano <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
PR-URL: #35208 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Masashi Hirano <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
PR-URL: #35208 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Masashi Hirano <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
PR-URL: #35208 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Masashi Hirano <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Untested, but the existing code looks just plain wrong - the more so because line 403 does call
fs.close.bind(fd)
.