npm / raw-body
raw-body
What changed in raw-body 4, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-18.
9 breaking2 new APIs and options2 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initraw-body 413 changes
Breaking changes 9
When no callback is provided, the function no longer checks for a global Promise.
A body exceeding its declared length now errors with 400 request.size.invalid as soon as excess bytes arrive, bounding memory even without a limit; length overruns take precedence over limit errors.
A limit that does not parse to a byte count now throws a TypeError instead of silently reading without a limit; limit: null explicitly disables the limit.
Streams1 support is removed. Streams must implement the readable stream interface; string chunks now error with 500 stream.encoding.set through the callback.
Streams destroyed without an error now settle through the callback or rejected promise with a 400 request.aborted error.
Node.js versions prior to 22 are no longer supported because the package relies on require(esm), which does not work correctly on earlier versions.
The package is now ESM-only; CommonJS consumers can continue loading it through require(esm).
Decoding no longer detects a big-endian BOM and always uses little-endian; use utf-16be for big-endian content.
Supported encodings now follow the WHATWG Encoding Standard; unsupported encodings throw a 415 error.
New APIs and options 2
A custom decoder compatible with iconv-lite's getDecoder can decode encodings outside the WHATWG Encoding Standard.
New export reads WHATWG ReadableStream bodies with the same options as getRawBody; getRawBody itself continues to accept only node streams.
Fixes and other changes 2
A custom decoder throwing while reading node streams no longer crashes the process.
Unparseable length values are treated as no expected length, avoiding request failures caused by values that parse to NaN.