Skip to content
This repository has been archived by the owner on Jun 12, 2022. It is now read-only.

Handle highWaterMark potentially false #72

Open
wants to merge 2 commits into
base: latest
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ module.exports = class Cache {
cacheTargetStream ? cacheTargetStream.end(done) : done()
})
const oldBody = response.body
const newBody = through({highWaterMark: fitInMemory && MAX_MEM_SIZE})
// in readable-stream 3.x, false is not a valid value for highWaterMark
const highWaterMark = fitInMemory ? MAX_MEM_SIZE : undefined
const newBody = through({highWaterMark})
response.body = newBody
oldBody.once('error', err => newBody.emit('error', err))
newBody.once('error', err => oldBody.emit('error', err))
Expand Down