Skip to content
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

Merged
merged 11 commits into from May 5, 2024
Merged

support onread in net #10753

merged 11 commits into from May 5, 2024

Conversation

gvilums
Copy link
Contributor

@gvilums gvilums commented May 2, 2024

What does this PR do?

Implements support for the onread option in node:net
Fixes #10719

How did you verify your code works?

Added a test

@@ -100,6 +100,11 @@ const Socket = (function (InternalSocket) {
data({ data: self }, buffer) {
if (!self) return;

if (self.#onreadCallback) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if (self.#onreadCallback) {
const onReadCallback = self.#onreadCallback;
if (onReadCallback) {
try {
onReadCallback(buffer.length, buffer);
} catch(e) {
self.emit("error", e);
}
return;
}

Copy link
Collaborator

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

Copy link
Contributor Author

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

@Jarred-Sumner Jarred-Sumner marked this pull request as draft May 2, 2024 00:21
Copy link

github-actions bot commented May 2, 2024

@gvilums, your commit has failing tests :(

💪 2 failing tests Darwin AARCH64

💻 1 failing tests Darwin x64

🐧💪 1 failing tests Linux AARCH64

🐧🖥 1 failing tests Linux x64 baseline

🪟💻 11 failing tests Windows x64 baseline

🪟💻 9 failing tests Windows x64

View logs

@gvilums gvilums marked this pull request as ready for review May 2, 2024 17:36
@Jarred-Sumner Jarred-Sumner merged commit 7bfcc2c into main May 5, 2024
40 of 52 checks passed
@Jarred-Sumner Jarred-Sumner deleted the georgijs/net-onread branch May 5, 2024 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

net's onread doesn't work as intended
2 participants