From 5c5470a0f2204b4164fcc65e210471661208ce4d Mon Sep 17 00:00:00 2001 From: Magnus <24817592+kunmagg@users.noreply.github.com> Date: Fri, 27 Oct 2023 12:52:09 +0200 Subject: [PATCH] fix: clone response early for response logging (#1799) Co-authored-by: Magnus Kunnas --- src/browser/setupWorker/start/createRequestListener.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/browser/setupWorker/start/createRequestListener.ts b/src/browser/setupWorker/start/createRequestListener.ts index b6ee1e56a..415094b36 100644 --- a/src/browser/setupWorker/start/createRequestListener.ts +++ b/src/browser/setupWorker/start/createRequestListener.ts @@ -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) /** @@ -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, }) })