Skip to content

Commit

Permalink
Fix issue #1753 Reject promise when workbook reader is writing to tem…
Browse files Browse the repository at this point in the history
…porary file stream and error occurs (#1756)

Co-authored-by: Paulius Grabauskas <paulius.grabauskas@devbridge.com>
Co-authored-by: Siemienik Pawel <hi@siemienik.com>
  • Loading branch information
3 people committed Apr 14, 2023
1 parent 478e2a0 commit 4acab1d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/stream/xlsx/workbook-reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class WorkbookReader extends EventEmitter {
waitingWorkSheets.push({sheetNo, path, tempFileCleanupCallback});

const tempStream = fs.createWriteStream(path);
tempStream.on('error', reject);
entry.pipe(tempStream);
return tempStream.on('finish', () => {
return resolve();
Expand Down Expand Up @@ -298,11 +299,8 @@ class WorkbookReader extends EventEmitter {
options: this.options,
});

const matchingRel = (this.workbookRels || []).find(
rel => rel.Target === `worksheets/sheet${sheetNo}.xml`
);
const matchingSheet =
matchingRel && (this.model.sheets || []).find(sheet => sheet.rId === matchingRel.Id);
const matchingRel = (this.workbookRels || []).find(rel => rel.Target === `worksheets/sheet${sheetNo}.xml`);
const matchingSheet = matchingRel && (this.model.sheets || []).find(sheet => sheet.rId === matchingRel.Id);
if (matchingSheet) {
worksheetReader.id = matchingSheet.id;
worksheetReader.name = matchingSheet.name;
Expand Down

0 comments on commit 4acab1d

Please sign in to comment.