Repository navigation
fix(pg-cloudflare): emit the destroy error so a connect timeout says why - #3810
Open
pedroapfilho wants to merge 1 commit into
Open
pedroapfilho wants to merge 1 commit into
pedroapfilho wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3809.
Client#connecttimes out withcon.stream.destroy(new Error('timeout expired')), andCloudflareSocket#destroydropped that error and only calledend(). The client then saw a bare'close'and rejected withConnection terminated unexpectedly.destroy(error)now does whatnet.Socket#destroy(error)does: it emits'error'with the reason, then'close'. The error is queued beforeend()runs, so it still arrives first when the socket'sclose()resolves right away.destroy()without an argument, which is every other call in pg and pg-pool, behaves as before.Tests, in
pg-esm-test/pg-cloudflare.test.js:destroy(error)emits that error, and before'close'(fails without this change)destroy()emits no errorChecked in workerd too (
wrangler dev,nodejs_compat,connectionTimeoutMillis: 500, a TCP listener that never answers):This touches
destroy()only, so it shouldn't conflict with #3784, #3806 or #3718.