Repository navigation
fix(node): read a pre-set rawBody from every body method - #312
Conversation
`arrayBuffer()`, `bytes()`, `blob()`, `formData()` and `body` rejected with "Body is unusable" when the stream was drained into `req.rawBody` (Google Cloud Functions, Firebase), while `text()` and `json()` read it. The `body` stream now comes from `rawBody` too, so `maxRequestBodySize` applies to all of them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@nitedani is attempting to deploy a commit to the unjs Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
…vx alone Reading `rawBody` directly skipped srvx's `maxRequestBodySize`: a body over the limit answered 200 where main answers 413. srvx serves `text()` and `json()` from `rawBody` under the limit, so a route's json() keeps working; its other reads ignore `rawBody` until h3js/srvx#312 is released. Co-Authored-By: Claude Opus 5.5 <[email protected]>
commit: |
On Google Cloud Functions, which reads the request stream into
req.rawBody,request.arrayBuffer(),bytes(),blob(),formData()andrequest.bodyfail withBody is unusable.text()andjson()work, because #295 made them readreq.rawBody.req.rawBodyset, thenrequest.arrayBuffer()(alsobytes(),blob(),formData(),body)TypeError: Body is unusablemaxRequestBodySizeliketext()#readBuffered()readsreq.rawBody, but thebodygetter, which every other method reads from, doesn't. This servesbodyfrom a Bufferreq.rawBody, so all of them read it through the existing size limit.What you should see
1. A server that fills
req.rawBodythe way Google Cloud Functions does, then reads the body witharrayBuffer():srvx 1.0.5 (also on
mainat f74d220), Node 26:On 8dea2bf it returns
hello.2. The new test reads an 8-byte and a 9-byte
rawBodythrough each of the seven ways (the six methods andbody) undermaxRequestBodySize: 8. Onmain, 5 of the 7 fail (text()andjson()pass); on 8dea2bf all 7 answer 200 for 8 bytes and 413ERR_BODY_TOO_LARGEfor 9.🤖 Generated with Claude Code
Summary by CodeRabbit