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

Fix handling of waiting for drain event #16

Open
kastermester opened this issue Jun 16, 2022 · 1 comment
Open

Fix handling of waiting for drain event #16

kastermester opened this issue Jun 16, 2022 · 1 comment
Labels

Comments

@kastermester
Copy link
Member

When sendToQueue returns false what is indicated is that it was not possible to write to the network stream right now - and instead the buffer is stored in user space memory for when the socket is ready again.

The current logic takes this to mean "the message could not be sent, wait for drain and try agian after this". This means that effectively we can end up sending the message twice when it is not needed.

@kastermester
Copy link
Member Author

kastermester commented Jun 16, 2022

See: https://nodejs.org/docs/latest-v14.x/api/net.html#net_socket_write_data_encoding_callback

Returns true if the entire data was flushed successfully to the kernel buffer. Returns false if all or part of the data was queued in user memory. 'drain' will be emitted when the buffer is again free.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant