fix: clone response before mutating it as of ISSUE-103#105
fix: clone response before mutating it as of ISSUE-103#105RobinBertilsson wants to merge 1 commit intovalendres:mainfrom
Conversation
|
@valendres could you please have a look? 🙏 |
| headers: rawHeaders, | ||
| body: rawBody, | ||
| }) => { | ||
| onMockedResponse: async (response) => { |
There was a problem hiding this comment.
I think it's much better to use a higher-level getResponse() instead of handleRequest(). Any history as to why handleRequest is used instead? Is it to tap into resolutionContext.baseUrl?
There was a problem hiding this comment.
Not sure i'm following... Where do you mean i would use handleRequest?
The only difference in this PR is that i accept the request parameter provided by onMockedResponse, which i then use to clone the response, before mutating it. The reason for the clone is because the stream is "locked" as per this error message.
ReadableStream is locked
There was a problem hiding this comment.
My comment isn't related to your changes. If you scroll a few lines above your change, you see the usage of handleRequest. Funneling the mocked response from onMockedResponse to Playwright isn't the best place so I'm suggesting using getResponse() instead.
As mentioned in ISSUE-103.