Minimal reproduction for nitrojs/nitro#3831.
defineCachedEventHandler corrupts binary responses because it uses res.text() to read the body before caching, converting binary data to UTF-8.
pnpm install
pnpm test00ff04050ac8962100ff
00efbfbd04050ac89621
0xff bytes are replaced with efbfbd (UTF-8 replacement character).
pnpm dev
curl -s http://localhost:3000/api/raw | xxd -p # correct: 00ff04050ac8962100ff
curl -s http://localhost:3000/api/binary | xxd -p # corrupted: 00efbfbd04050ac89621See fix/patch branch for a pnpm patch that fixes the issue by using res.arrayBuffer() and base64 encoding for cache storage.