Repository navigation
Cloudflare Workers: open the socket secure from the first byte for sslnegotiation: 'direct' - #1272
Open
dinodeSimon wants to merge 1 commit into
Open
dinodeSimon wants to merge 1 commit into
dinodeSimon wants to merge 1 commit into
Conversation
…lnegotiation: 'direct'
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.
sslnegotiation: 'direct'(Postgres 17: TLS from the first byte, no SSLRequest round trip) is accepted by the options and skips the SSLRequest insrc/connection.js, but on Cloudflare Workers the connection then never finishes:cf/polyfills.jsopens the socket withsecureTransport: 'starttls'and itstls.connectupgrades it withstartTls(), which a direct connection never asks for the server to agree to, so the connect times out (CONNECT_TIMEOUT).This opens the socket with
secureTransport: 'on'when the connection is direct, and has the shim'stls.connectonly say it is connected (there is nothing to upgrade).socket.directis set insrc/connection.jsbesidesocket.ssl; thecf,cjsanddenocopies are regenerated with the transpile scripts. Nothing changes for the othersslnegotiationvalues.Tested from a Worker against Neon's pooler (Sydney): a client a call, nine reads each, interleaved six times, 60 calls each: p50 26-27 ms with
directagainst 26-30 ms without (about 2 ms, the SSLRequest round trip), no errors. Neon's pooler accepted the handshake without ALPN (Workers'connect()takes no ALPN option).