-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
support onread in net #10753
support onread in net #10753
Conversation
src/js/node/net.ts
Outdated
@@ -100,6 +100,11 @@ const Socket = (function (InternalSocket) { | |||
data({ data: self }, buffer) { | |||
if (!self) return; | |||
|
|||
if (self.#onreadCallback) { |
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.
if (self.#onreadCallback) { | |
const onReadCallback = self.#onreadCallback; | |
if (onReadCallback) { | |
try { | |
onReadCallback(buffer.length, buffer); | |
} catch(e) { | |
self.emit("error", e); | |
} | |
return; | |
} |
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.
Ideally, we'd have a separate handlers object and not do this check here on every single call to onData
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.
Changed to use a separate handlers object
…into georgijs/net-onread
…into georgijs/net-onread
What does this PR do?
Implements support for the
onread
option innode:net
Fixes #10719
How did you verify your code works?
Added a test