From d62706399279bcca6aec03aee7ebb2d4355885b8 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 25 Oct 2023 22:58:46 -0400 Subject: [PATCH] fix(createWebWorkerPromise): clean up object urls --- src/core/createWebWorkerPromise.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/createWebWorkerPromise.ts b/src/core/createWebWorkerPromise.ts index a4947ea5e..3a37a65e6 100644 --- a/src/core/createWebWorkerPromise.ts +++ b/src/core/createWebWorkerPromise.ts @@ -41,7 +41,9 @@ async function createWebWorkerPromise (existingWorker: Worker | null, pipelineWo const webWorkerString = webWorkersUrl as string if (webWorkerString.startsWith('http')) { const response = await axios.get(`${webWorkerString}/bundles/pipeline.${min}worker.js`, { responseType: 'blob' }) - worker = new Worker(URL.createObjectURL(response.data as Blob)) + const workerObjectUrl = URL.createObjectURL(response.data as Blob) + worker = new Worker(workerObjectUrl) + URL.revokeObjectURL(workerObjectUrl) } else { worker = new Worker(`${webWorkerString}/bundles/pipeline.${min}worker.js`) } @@ -53,7 +55,9 @@ async function createWebWorkerPromise (existingWorker: Worker | null, pipelineWo } else { if (workerUrl.startsWith('http')) { const response = await axios.get(workerUrl, { responseType: 'blob' }) - worker = new Worker(URL.createObjectURL(response.data as Blob)) + const workerObjectUrl = URL.createObjectURL(response.data as Blob) + worker = new Worker(workerObjectUrl) + URL.revokeObjectURL(workerObjectUrl) } else { worker = new Worker(workerUrl) }