Skip to content

onmax/nitro-binary-cache-repro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nitro v3 Binary Cache Corruption Repro

Minimal reproduction for nitrojs/nitro#3831.

Bug

defineCachedEventHandler corrupts binary responses because it uses res.text() to read the body before caching, converting binary data to UTF-8.

Repro

pnpm install
pnpm test

Expected output

00ff04050ac8962100ff

Actual output (corrupted)

00efbfbd04050ac89621

0xff bytes are replaced with efbfbd (UTF-8 replacement character).

Manual test

pnpm dev
curl -s http://localhost:3000/api/raw | xxd -p     # correct: 00ff04050ac8962100ff
curl -s http://localhost:3000/api/binary | xxd -p  # corrupted: 00efbfbd04050ac89621

Fix

See fix/patch branch for a pnpm patch that fixes the issue by using res.arrayBuffer() and base64 encoding for cache storage.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published