File tree 1 file changed +4
-1
lines changed
1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -326,7 +326,10 @@ export default class Request extends Duplex implements RequestEvents<Request> {
326
326
// Node.js parser is really weird.
327
327
// It emits post-request Parse Errors on the same instance as previous request. WTF.
328
328
// Therefore we need to check if it has been destroyed as well.
329
- if ( response && ! response . rawBody && ! this . _request ?. socket ?. destroyed ) {
329
+ //
330
+ // Furthermore, Node.js 16 `response.destroy()` doesn't immediately destroy the socket,
331
+ // but makes the response unreadable. So we additionally need to check `response.readable`.
332
+ if ( response ?. readable && ! response . rawBody && ! this . _request ?. socket ?. destroyed ) {
330
333
// @types /node has incorrect typings. `setEncoding` accepts `null` as well.
331
334
response . setEncoding ( this . readableEncoding ! ) ;
332
335
You can’t perform that action at this time.
0 commit comments