Skip to content

Commit 535facd

Browse files
committed
fix: free request parser on close
1 parent 97f678b commit 535facd

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/interceptors/http/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,16 @@ function createHttpRequestParserStream(options: {
229229
body: canHaveBody ? (Readable.toWeb(requestBodyStream) as any) : null,
230230
})
231231

232+
/**
233+
* @note Here we used to skip the request handling altogether
234+
* if the "INTERNAL_REQUEST_ID_HEADER_NAME" request header is present.
235+
* That prevented the nested interceptors (XHR -> ClientRequest) from
236+
* conflicting. Do we still need this?
237+
*
238+
* @todo Forgo the old deduplication algo because it's intrusive.
239+
* @see https://github.com/mswjs/interceptors/issues/378
240+
*/
241+
232242
options.onRequest(request)
233243
},
234244
onBody(chunk) {
@@ -253,7 +263,7 @@ function createHttpRequestParserStream(options: {
253263

254264
parserStream
255265
.once('finish', () => parser.free())
256-
.once('error', () => parser.free())
266+
.once('close', () => parser.free())
257267

258268
return parserStream
259269
}

0 commit comments

Comments
 (0)