Skip to content

Wake JS on libuv poll errors instead of dropping the callback - #137

Open
nigrosimone wants to merge 2 commits into
brianc:masterfrom
nigrosimone:fix-poll-error
Open

Wake JS on libuv poll errors instead of dropping the callback#137
nigrosimone wants to merge 2 commits into
brianc:masterfrom
nigrosimone:fix-poll-error

Conversation

@nigrosimone

@nigrosimone nigrosimone commented Aug 9, 2026

Copy link
Copy Markdown

on_io_readable and on_io_writable look only at revents. But libuv signals a poll error with
status < 0 and revents == 0, and before calling the callback it already runs uv__io_stop and
uv__handle_stop, so the fd is out of the loop and no other event can arrive.

The result is that a connection reset by the peer becomes silent while it still looks alive.

I found it with pipelined queries in pg-native, where losing a backend in the middle of a batch left
the client with a connection that never completes and never fails.

@brianc

brianc commented Aug 12, 2026

Copy link
Copy Markdown
Owner

amazing job on writing tests for this, ty!!

@nigrosimone

Copy link
Copy Markdown
Author

The tests are success, but the ci hang to exit

@nigrosimone

nigrosimone commented Aug 12, 2026

Copy link
Copy Markdown
Author

@brianc my bad! my test don't close the sockets connections in https://github.com/brianc/node-libpq/pull/137/changes#diff-399651cdf8269b054efafa4155e009dbcb08f02e1fa57847e25d387974a8911eR34 I need to push a fix for the test

afterEach(function (done) {
  sockets.forEach(function (s) { s.destroy() }) // close all sockets
  proxy.close(function () { done() }) 
})

done 5c96d5b

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.

2 participants