Skip to content

Commit

Permalink
fix(parsing): Pass errors through callbacks
Browse files Browse the repository at this point in the history
Don't make assumptions that users want the file stream destroyed when an error is encountered
  • Loading branch information
foxmicha authored and doug-martin committed Jun 23, 2020
1 parent a4a1e3f commit 84ecdf6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/parse/src/CsvParserStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class CsvParserStream<I extends Row, O extends Row> extends Transform {
const rows = this.parse(newLine, true);
return this.processRows(rows, done);
} catch (e) {
return this.destroy(e);
return done(e);
}
}

Expand Down Expand Up @@ -114,7 +114,7 @@ export class CsvParserStream<I extends Row, O extends Row> extends Transform {
const iterate = (i: number): void => {
const callNext = (err?: Error): void => {
if (err) {
return this.destroy(err);
return cb(err);
}
if (i % 100 === 0) {
// incase the transform are sync insert a next tick to prevent stack overflow
Expand Down

0 comments on commit 84ecdf6

Please sign in to comment.