Skip to content

fs/promises: fix fd resource cleanup - #35208

Closed
bnoordhuis wants to merge 1 commit into
nodejs:masterfrom
bnoordhuis:fix-fs-promises-fd-close
Closed

fs/promises: fix fd resource cleanup#35208
bnoordhuis wants to merge 1 commit into
nodejs:masterfrom
bnoordhuis:fix-fs-promises-fd-close

Conversation

@bnoordhuis

Copy link
Copy Markdown
Member

Untested, but the existing code looks just plain wrong - the more so because line 403 does call fs.close.bind(fd).

@nodejs-github-botnodejs-github-bot added the fs Issues and PRs related to the fs subsystem / file system. label Sep 15, 2020
@cjihrig

Copy link
Copy Markdown
Contributor

Looking at git blame, it looks like d00d81e intentionally removed the bind() calls.

Comment threadlib/internal/fs/promises.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
returnfchmod(fd,mode).finally(fd.close.bind(fd));
returnfchmod(fd,mode).finally(FunctionPrototypeBind(fd.close,fd));

@mscdex

Copy link
Copy Markdown
Contributor

Is there a way we can add a test for this?

@bnoordhuis
bnoordhuisforce-pushed the fix-fs-promises-fd-close branch from 3cf0f4d to ae6aea0CompareSeptember 15, 2020 16:42
@bnoordhuis

Copy link
Copy Markdown
MemberAuthor

Looking at git blame, it looks like d00d81e intentionally removed the bind() calls.

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 .bind() call on line 403.

@addaleaxaddaleax added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 21, 2020
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 21, 2020
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@lpincalpinca added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 4, 2020
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 4, 2020
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@aduh95aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 7, 2020
@github-actionsgithub-actionsBot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 7, 2020
@github-actions

Copy link
Copy Markdown
Contributor
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()

PR-URL: #35208
Reviewed-By: Colin Ihrig cjihrig@gmail.com
Reviewed-By: Masashi Hirano shisama07@gmail.com
Reviewed-By: Anna Henningsen anna@addaleax.net

[master b25ae7178e] fs/promise: remove unnecessary Function#bind()
Author: Ben Noordhuis info@bnoordhuis.nl
Date: Tue Sep 15 18:40:39 2020 +0200
1 file changed, 1 insertion(+), 1 deletion(-)
✖ b25ae7178e8188d6b3ff3a0841d7aa5b54532e6d
✔ 0:0 skipping fixes-url fixes-url
✔ 0:0 blank line after title line-after-title
✔ 0:0 line-lengths are valid line-length
✔ 0:0 metadata is at end of message metadata-end
✔ 1:8 PR-URL is valid. pr-url
✔ 0:0 reviewers are valid reviewers
✖ 0:0 Invalid subsystem: "fs/promise" subsystem
✔ 0:0 Title is formatted correctly. title-format
✔ 0:0 Title is <= 50 columns. title-length

ℹ Please fix the commit message and try again.

Commit Queue action: https://github.com/nodejs/node/actions/runs/351509796

@github-actionsgithub-actionsBot added the commit-queue-failed An error occurred while landing this pull request using GitHub Actions. label Nov 7, 2020
aduh95 pushed a commit that referenced this pull request Nov 7, 2020
PR-URL: #35208
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Masashi Hirano <shisama07@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@aduh95

Copy link
Copy Markdown
Contributor

Landed in f06f3c0

@aduh95aduh95 closed this Nov 7, 2020
danielleadams pushed a commit that referenced this pull request Nov 9, 2020
PR-URL: #35208
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Masashi Hirano <shisama07@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@danielleadamsdanielleadams mentioned this pull request Nov 9, 2020
BethGriggs pushed a commit that referenced this pull request Dec 9, 2020
PR-URL: #35208
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Masashi Hirano <shisama07@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
BethGriggs pushed a commit that referenced this pull request Dec 10, 2020
PR-URL: #35208
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Masashi Hirano <shisama07@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@BethGriggsBethGriggs mentioned this pull request Dec 10, 2020
BethGriggs pushed a commit that referenced this pull request Dec 15, 2020
PR-URL: #35208
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Masashi Hirano <shisama07@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@targostargos removed the commit-queue-failed An error occurred while landing this pull request using GitHub Actions. label Sep 5, 2021
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fsIssues and PRs related to the fs subsystem / file system.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants

@bnoordhuis@cjihrig@mscdex@nodejs-github-bot@aduh95@addaleax@shisama@crypt096@lpinca@targos