Skip to content

Commit

Permalink
Merge pull request #1304 from tediousjs/arthur/unpipe-payload
Browse files Browse the repository at this point in the history
fix: unpipe payload streams on cancel or error
  • Loading branch information
arthurschreiber authored Aug 1, 2021
2 parents 9865073 + f195526 commit 3f57180
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3244,6 +3244,8 @@ class Connection extends EventEmitter {
request.rst! = [];

const onCancel = () => {
payloadStream.unpipe(message);

// set the ignore bit and end the message.
message.ignore = true;
message.end();
Expand Down Expand Up @@ -3274,6 +3276,8 @@ class Connection extends EventEmitter {

const payloadStream = (Readable as any).from(payload!) as Stream;
payloadStream.once('error', (error) => {
payloadStream.unpipe(message);

// Only set a request error if no error was set yet.
request.error ??= error;

Expand Down

0 comments on commit 3f57180

Please sign in to comment.