Skip to content

Commit

Permalink
fix chunked encoding errors in npm
Browse files Browse the repository at this point in the history
  • Loading branch information
everett1992 committed Oct 12, 2021
1 parent ff3d03c commit 4c26ad6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ const remoteFetch = (request, options) => {
// we got a 200 response and the user has specified an expected
// integrity value, so wrap the response in an ssri stream to verify it
const integrityStream = ssri.integrityStream({ integrity: _opts.integrity })
res = new fetch.Response(new MinipassPipeline(res.body, integrityStream), res)

// This should be equiv to `new MinipassPipeline(res.body, integrityStream)`
// but that causes currupted data with some chunked encoding.
const body = res.body.pipe(integrityStream)
res.body.on('error', err => integrityStream.emit('error', er))

res = new fetch.Response(body, res)
}

res.headers.set('x-fetch-attempts', attemptNum)
Expand Down

0 comments on commit 4c26ad6

Please sign in to comment.