SIGN IN SIGN UP

fix(node): send gzip bytes instead of a Blob request body (#4614)

* fix(node): send gzip bytes instead of a Blob request body

#4423 moved Node compression to node:zlib, which removed the Blob reads in
validateNativeGzip, but the compressed payload was still wrapped in a Blob
and handed to fetch as the request body. On Node 24.16+ every Blob read
leaks a native BlobReader that stays registered on the Node Environment for
the life of the process (nodejs/node#63574), so one still leaked per request.

Return the Uint8Array directly and widen the body type through the places it
flows. Measured on posthog-node 5.50.0 with capture() + flush() per request:
2.29 KB of retained heap per capture before, flat after, with 4,201 live
BlobReaders dropping to zero. Compression, headers and the wire format are
unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(node): type the gzip body without generic typed arrays

TypeScript added generic typed arrays in 5.7, so `Uint8Array<ArrayBuffer>` in the
published declarations fails with TS2315 for consumers on older versions that
compile without skipLibCheck.

`Uint8Array & { buffer: ArrayBuffer }` says the same thing, parses on TypeScript
4.7, and still satisfies `BodyInit`, so the fetch boundary stays cast-free and
the wire format is untouched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* chore: update public API references

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Manoel Aranda Neto <marandaneto@gmail.com>
O
Omid Sayfun committed
3593c43e98269cbe0bc18e697d38b8c862419b09
Parent: cedf844
Committed by GitHub <noreply@github.com> on 8/24/2026, 10:45:30 AM