Describe the bug
pglite-socket does not handle the PostgreSQL SSLRequest startup packet (8 bytes: Int32 length 8, then Int32 80877103). Per the protocol message formats, the server must respond with a single byte S or N before the client sends StartupMessage. Many clients (e.g. JDBC with default SSL negotiation) send SSLRequest first.
Without this handling, the 8 bytes are interpreted as a different frame shape and the message buffer never completes a valid packet, so the connection hangs or appears unresponsive during startup.
To Reproduce - include code sample(s)
import { connect } from 'node:net'
import { PGlite } from '@electric-sql/pglite'
import { PGLiteSocketServer } from '@electric-sql/pglite-socket'
const db = await PGlite.create()
await db.waitReady
const server = new PGLiteSocketServer({
db,
host: '127.0.0.1',
port: 0,
maxConnections: 4,
})
await server.start()
const port = Number(server.getServerConn().split(':').pop())
const buf = Buffer.alloc(8)
buf.writeInt32BE(8, 0)
buf.writeInt32BE(80877103, 4)
await new Promise((resolve, reject) => {
const s = connect(port, '127.0.0.1', () => s.write(buf))
s.setTimeout(2000, () => {
s.destroy()
reject(new Error('timeout: expected single-byte N'))
})
s.once('data', (d) => {
console.log('got', d) // expect <Buffer 4e> ('N')
s.destroy()
resolve()
})
s.on('error', reject)
})
await server.stop()
await db.close()
Alternatively: connect with a JDBC client (e.g. DBeaver) using default SSL-related settings; the client sends SSLRequest first and the connection can stall without a proper N response.
Logs
No logs
Details
- PGlite version 0.4.5
- pglite-socket version 0.1.5
- using any extensions? which ones? No
- OS version Windows 11
- nodejs v24.15.0
Describe the bug
pglite-socket does not handle the PostgreSQL SSLRequest startup packet (8 bytes: Int32 length 8, then Int32 80877103). Per the protocol message formats, the server must respond with a single byte S or N before the client sends StartupMessage. Many clients (e.g. JDBC with default SSL negotiation) send SSLRequest first.
Without this handling, the 8 bytes are interpreted as a different frame shape and the message buffer never completes a valid packet, so the connection hangs or appears unresponsive during startup.
To Reproduce - include code sample(s)
Alternatively: connect with a JDBC client (e.g. DBeaver) using default SSL-related settings; the client sends SSLRequest first and the connection can stall without a proper N response.
Logs
No logs
Details