Skip to content

Commit

Permalink
Merge pull request #1305 from tediousjs/arthur/only-destroy-with-erro…
Browse files Browse the repository at this point in the history
…r-when-streaming

fix: only destroy with error when in streaming mode
  • Loading branch information
arthurschreiber authored Aug 1, 2021
2 parents 3f57180 + 584d748 commit a99949f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/bulk-load-payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@ export class BulkLoadPayload implements AsyncIterable<Buffer> {
this.bulkLoad.removeListener('cancel', onCancel);
});

const onCancel = () => {
this.bulkLoad.rowToPacketTransform.destroy(new RequestError('Canceled.', 'ECANCEL'));
};
let onCancel: () => void;
if (this.bulkLoad.streamingMode) {
onCancel = () => {
this.bulkLoad.rowToPacketTransform.destroy(new RequestError('Canceled.', 'ECANCEL'));
};
} else {
onCancel = () => {
this.bulkLoad.rowToPacketTransform.destroy();
};
}

this.bulkLoad.once('cancel', onCancel);
}
Expand Down

0 comments on commit a99949f

Please sign in to comment.