adelsz / pgtyped

pgTyped - Typesafe SQL in TypeScript
https://pgtyped.dev
MIT License
2.97k stars 97 forks source link

Fix fragmented TCP packet handling #487

Closed adelsz closed 1 year ago

adelsz commented 1 year ago

This fixes an issue with handling of fragmented TCP packets. The problem was uncovered in https://github.com/adelsz/pgtyped/issues/474. The type inference query result for such a big enum sometimes doesn't fit into a single TCP packet so it gets split into two, with the boundary cutting a PGSQL protocol frame in half. Solution is to concat TCP packets into a single Buffer as we receive them to make them continuous for the parsing routines. Memory is cleaned up by unreferencing the Buffer on PGSQL frame boundaries.

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
pgtyped ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 2, 2023 at 1:15AM (UTC)