Skip to content

Commit

Permalink
fix: createServerResponse duplicate onReadable calls
Browse files Browse the repository at this point in the history
  • Loading branch information
nitedani committed Aug 19, 2024
1 parent 387b664 commit ea74587
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ import { PassThrough, Readable } from 'stream'
function createServerResponse(incomingMessage: IncomingMessage) {
const res = new ServerResponse(incomingMessage)
const passThrough = new PassThrough()
let handled = false

const onReadable = (
cb: (result: { readable: Readable; headers: OutgoingHttpHeaders; statusCode: number }) => void
) => {
const handleReadable = () => {
if (handled) return
handled = true
cb({ readable: Readable.from(passThrough), headers: res.getHeaders(), statusCode: res.statusCode })
}

Expand Down

0 comments on commit ea74587

Please sign in to comment.