Home / Companies / Neon / Blog / Post Details
Content Deep Dive

When LIMIT 9 works but LIMIT 10 hangs

Blog post from Neon

Post Details
Company
Date Published
Author
George MacKerron
Word Count
2,599
Language
English
Hacker News Points
-
Summary

In a detailed debugging narrative, a developer investigates a persistent issue where a SQL query utilizing WebSockets consistently fails when executed with an ORDER BY clause in Node 18 and above, but not in Node 17 and below. The problem is attributed to the WebSocket support in the experimental undici package, which mismanaged payload length encoding for larger queries, leading to inconsistent and erroneous behavior. By examining network packets using Wireshark and understanding the WebSocket framing protocol, the developer identified that the undici package incorrectly set payload lengths beyond a certain threshold, causing the connection to hang or terminate unexpectedly. The resolution involved modifying the undici code to correctly handle the buffer allocation and payload length encoding, which was successfully merged and released in an updated version of the package. This investigation highlights the importance of understanding low-level protocol details and the potential pitfalls of optimization techniques that compromise reliability.