-
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: do not emit open and read if stream destroyed #24055
Conversation
@nodejs/fs @mcollina |
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.
Thanks for getting started with this! I think it's almost there.
lib/internal/fs/streams.js
Outdated
if (isOpen) { | ||
this.once('open', closeFsStream.bind(null, this, cb, err)); | ||
// if stream is not open it will be closed in open() | ||
if (typeof this.fd !== 'number') |
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.
we are swallowing the original error here.
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.
LGTM
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.
fine by me
🔥🔥 alternatively we could just burn streams to the ground and start again, after this security release I'm in the mood 🔥🔥
This reverts commit a26991b.
lib/internal/fs/streams.js
Outdated
closeFsStream(this, (er) => { | ||
if (er) { | ||
this.emit('error', er); | ||
} |
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.
This will cause error to be emitted after close. I think we should swallow this error.
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.
I removed it and the error still got emitted. The error
event does not seem to come from lib/internal/fs/streams.js... 🤔
Path: parallel/test-fs-stream-no-events-after-destroy
assert.js:128
throw err;
^
AssertionError [ERR_ASSERTION]: function should not have been called at /Users/hackintosh/Documents/code/node/test/parallel/test-fs-stream-no-events-after-destroy.js:15
at ReadStream.mustNotCall (/Users/hackintosh/Documents/code/node/test/common/index.js:404:12)
at ReadStream.emit (events.js:189:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at internalTickCallback (internal/process/next_tick.js:72:19)
at process._tickCallback (internal/process/next_tick.js:47:5)
at Function.Module.runMain (internal/modules/cjs/loader.js:778:11)
at startup (internal/bootstrap/node.js:300:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:826:3)
There are about 2 tests failing:
On various environments. If they pass locally, it means they are flaky on CI: you can run a stress test locally with While you are working on it, could you also rebase on top of master? |
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.
Using "request changes" so that it does not get landed until tests are fixed.
Ping @dexterleng 🔉 |
Im not sure how to prevent errors from being swallowed. node/lib/internal/fs/streams.js Line 137 in 930c8d4
If someone else knows how to fix this please help out. |
I don't understand what is the problem you are facing as the change looks fine to me. It seems some tests would require some changes as a result |
ping @dexterleng . Is this something you are planning to work on? |
@antsmartian I am no longer working on it. |
8ae28ff
to
2935f72
Compare
Closing due to lack of continued activity |
WIP, will write tests ASAP.
References: #23133
Addresses this:
@mcollina I don’t understand… I’m not talking about changing emit() to be a noop function or so, I’m talking about the individual call sites in our own net, tls, fs, etc. code?
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes