Skip to content

Commit

Permalink
Ensure we close file handles and streams
Browse files Browse the repository at this point in the history
  • Loading branch information
porsager committed Feb 18, 2024
1 parent defa97c commit e934bbf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ function stream(r, type, { handle, stat, compressor }, options) {
compressor
? r.header('Transfer-Encoding', 'chunked')
: r.header('Content-Length', size)
return r.end()
return Promise.resolve(r.end())
}

return compressor
Expand Down Expand Up @@ -574,6 +574,11 @@ async function streamCompressed(r, handle, compressor, highWaterMark, total, sta
, reject
, resume

r.onAborted(() => {
resume && resume()
compressStream.destroy()
})

const promise = new Promise((r, e) => (resolve = r, reject = e))

compressStream.on('data', x => ok = r.write(x))
Expand Down

0 comments on commit e934bbf

Please sign in to comment.