From cbe6f652f2c610bf21a35f13b8e86450c9e65fc0 Mon Sep 17 00:00:00 2001 From: David Whittington Date: Fri, 21 Jul 2023 12:53:04 -0500 Subject: [PATCH] fix(bundles ans-104): handle errors unlinking temporary bundle file PE-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. --- src/lib/ans-104.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/ans-104.ts b/src/lib/ans-104.ts index 6599df5c..6a284ef8 100644 --- a/src/lib/ans-104.ts +++ b/src/lib/ans-104.ts @@ -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); + } } }); }