Skip to content

Commit

Permalink
fix: clone response early for response logging (#1799)
Browse files Browse the repository at this point in the history
Co-authored-by: Magnus Kunnas <[email protected]>
  • Loading branch information
kunmagg and Magnus Kunnas authored Oct 27, 2023
1 parent 1d1fbca commit 5c5470a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/browser/setupWorker/start/createRequestListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const createRequestListener = (
// to buffer to be sent to the worker and also in the
// ".log()" method of the request handler.
const responseClone = response.clone()
const responseCloneForLogs = response.clone()
const responseInit = toResponseInit(response)

/**
Expand All @@ -72,10 +73,10 @@ export const createRequestListener = (
}

if (!options.quiet) {
context.emitter.once('response:mocked', ({ response }) => {
context.emitter.once('response:mocked', () => {
handler.log({
request: requestCloneForLogs,
response,
response: responseCloneForLogs,
parsedResult,
})
})
Expand Down

0 comments on commit 5c5470a

Please sign in to comment.