-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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: avoid emitting error EBADF for double close #11225
Conversation
Given that this affects error handling it technically should be considered for semver-major. However, I think it qualifies as a bug fix so leaving it as semver-patch. |
|
||
common.refreshTmpDir(); | ||
|
||
const s = fs.createWriteStream(path.join(common.tmpDir, '/rw')); |
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.
Can you remove the /
before rw
.
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.
fixed
Changed the logic in fs.ReadStream and fs.WriteStream so that close always calls the prototype method rather than the internal event listener. Fixes: nodejs#2950
@jasnell I added the don't land on LTS labels, just in case. |
Minor nit: there's a typo in the commit message |
Another reason not to land on v4.x and v6.x is the use of |
If we aren't planning on backporting this, I think we should go ahead and mark as semver-major (especially given that it seems like a breaking change) |
We can just use an arrow function instead? |
If that's the only problem, yes of course. |
Landed as b1fc774 |
Changed the logic in fs.ReadStream and fs.WriteStream so that close always calls the prototype method rather than the internal event listener. Fixes: #2950 PR-URL: #11225 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Evan Lucas <[email protected]>
Changed the logic in fs.ReadStream and fs.WriteStream so that close always calls the prototype method rather than the internal event listener. Fixes: nodejs#2950 PR-URL: nodejs#11225 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Evan Lucas <[email protected]>
@Fishrock123 yes. I'm happy for it to be backported, but we were not in agreement. If we agree that this is not semver-major, we can backport. I can fire a PR. |
I don't know if this is pressing enough that it needs to be backported, but I don't feel strongly either way. |
@mcollina Now that I look at this again, I think we could have avoided the this.once('open', this.close); which is more easily backportable. Maybe submit a separate PR for the |
@mscdex we cannot, because |
@mcollina Ok well we could still pull out a reusable function and do it that way: this.once('open', closeOnOpen);
// ...
function closeOnOpen() {
this.close(null);
} |
here it is: #13474 |
nodejs#11225 introduce an unnecessary bind() when closing a stream. This PR replaces that bind() with a top-level function. PR-URL: nodejs#13474 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Brian White <[email protected]> Reviewed-By: Evan Lucas <[email protected]>
nodejs#11225 introduce an unnecessary bind() when closing a stream. This PR replaces that bind() with a top-level function. PR-URL: nodejs#13474 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Brian White <[email protected]> Reviewed-By: Evan Lucas <[email protected]>
#11225 introduce an unnecessary bind() when closing a stream. This PR replaces that bind() with a top-level function. PR-URL: #13474 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Brian White <[email protected]> Reviewed-By: Evan Lucas <[email protected]>
Changed the logic in fs.ReadStream and fs.WriteStream so that
close always calls the prototype method rather than the internal
event listener.
Fixes: #2950
cc @evanlucas @Trott @bnoordhuis
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
fs, stream