Skip to content

Commit

Permalink
Fix request destroy check for Node.js 12
Browse files Browse the repository at this point in the history
  • Loading branch information
szmarczak committed Apr 13, 2021
1 parent 7ccc0b8 commit 78b105b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion source/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ export default class Request extends Duplex implements RequestEvents<Request> {
// Node.js parser is really weird.
// It emits post-request Parse Errors on the same instance as previous request. WTF.
// Therefore we need to check if it has been destroyed as well.
if (response && !response.rawBody && !this._request?.destroyed) {
if (response && !response.rawBody && !this._request?.socket?.destroyed) {
// @types/node has incorrect typings. `setEncoding` accepts `null` as well.
response.setEncoding(this.readableEncoding!);

Expand Down

0 comments on commit 78b105b

Please sign in to comment.