When LIMIT 9 works but LIMIT 10 hangs
A Postgres query over Neon's serverless driver hung only when its WebSocket payload reached 126 bytes, the threshold where WebSocket framing switches to a 16-bit extended length field. The cause was in undici's frame encoder, which wrote that length with a DataView over the buffer's backing ArrayBuffer at offset zero. Buffer.allocUnsafe() hands out small buffers as slices of a shared 8 KB pool, so the length bytes held garbage and the real length was written over other live buffers. The fix used writeUInt16BE(), shipped in undici 5.22.1, and a benchmark showed it is more than twice as fast as the DataView "optimization".
Related posts
- Quicker serverless Postgres connections
Neon mediumAdept
Neon cut the network round-trips needed to get a first query result from its WebSocket-based serverless Postgres driver from nine to four. It moved to TLS 1.3, ran Postgres unencrypted inside a secure wss: WebSocket (or pipelined SSLRequest with the TLS Client Hello), and replaced CPU-heavy SCRAM-SHA-256 with plain password auth over TLS, since Neon only issues long random passwords. It also pipelined the startup, password and query messages into a single send. Pipelining at first added up to 50ms of delay over short distances because of Nagle's algorithm, fixed by setting TCP_NODELAY in the proxy. QUIC-based WebSockets or WebTransport might cut the count further.
- Edge-compatible Serverless Driver for Postgres
Neon mediumAdept
Neon's @neondatabase/serverless driver lets V8-isolate platforms like Cloudflare Workers, which lack TCP, speak the real Postgres wire protocol by tunnelling it over a WebSocket to an open-source Go proxy that relays to TCP. The driver is node-postgres with shims for Node APIs, and it does end-to-end TLS 1.3 via WolfSSL compiled to WebAssembly with Asyncify, offloading crypto to SubtleCrypto. Because SCRAM-SHA-256's 4,096 hash rounds exceed Workers' 10–50ms CPU limits, it falls back to cleartext auth over mandatory TLS. The post also covers latency tradeoffs from the extra proxy hop, round-trip reductions, and how to self-host the proxy for any Postgres.
- Using Neon’s Scale to Zero with Long-Running Applications
Neon mediumAdept
Neon's scale to zero suspends a Postgres compute after an idle window (only when no WAL senders are active and autovacuum isn't running), which severs connections held by long-running servers. A naive node-postgres Client crashes on the resulting unhandled error event. A client-side pg.Pool with an error handler tolerates the dropped connections and reconnects on demand, waking the database. In Apache Bench tests the pool beat per-request connections by more than 10x (about 46ms vs 678ms average latency, 370 vs 26 req/s), with the same pattern shown in a Fastify, Drizzle and HTMX example app.
- Bun v1.1.23
Bun mediumAdept
Bun v1.1.23 fixes 27 bugs and adds TextEncoderStream/TextDecoderStream, the TextDecoder stream option, Float16Array, and truncation of large arrays in console.log after 100 elements. console.log(string) is 50% faster: a single-string fast path that still needed extra writes for the newline and ANSI reset was dropped in favor of buffered writes. Bun now throws proper errors instead of crashing or truncating when Blob/Request/Response bodies or fs.readFile exceed JavaScriptCore's 2^32-1 length limit. Other fixes cover duplicate sends caused by mishandled backpressure in the ws module, Bun-to-Node IPC on Windows, JIT crashes in node:vm contexts, bundler hoisting of tagged template literals, and >4GB responses from Bun.serve.
- Bun v1.2.18
Bun mediumAdept
Bun v1.2.18 fixes 52 issues and adds ReadableStream .text()/.json()/.bytes()/.blob(), ReadableStream stdin for Bun.spawn, permessage-deflate compression for the WebSocket client, and Math.sumPrecise. Large fetch() and S3 uploads now apply backpressure, pausing stream reads while the socket is busy so memory stays flat, and S3 writer.flush() resolves after each part uploads. Native addon performance improves: napi_create_buffer skips zero-initialization for about 30% faster large allocations, and sliced strings are no longer cloned. Node.js compatibility work includes reporting as Node v24.3.0, fs.glob matching directories by default, and http2 remoteSettings and net error-handling fixes.