Skip to content

Commit

Permalink
fix(bundles ans-104): handle errors unlinking temporary bundle file P…
Browse files Browse the repository at this point in the history
…E-4212

During ANS-104 parsing we create a temporary files to pass data between
the main thread and the parser thread. After parsing is complete the
files are removed. This change ensures that errors during temporary file
cleanup are correctly handled without crashing the worker thread.
  • Loading branch information
djwhitt committed Jul 21, 2023
1 parent bf32468 commit cbe6f65
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib/ans-104.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,11 @@ if (!isMainThread) {
log.error('Error unbundling ANS-104 bundle stream', error);
parentPort?.postMessage({ eventName: 'unbundle-error' });
} finally {
await fsPromises.unlink(bundlePath);
try {
await fsPromises.unlink(bundlePath);
} catch (error) {
log.error('Error deleting ANS-104 temporary bundle file', error);
}
}
});
}

0 comments on commit cbe6f65

Please sign in to comment.