Skip to content

Commit

Permalink
fix(createWebWorkerPromise): clean up object urls
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Oct 26, 2023
1 parent d6d24f0 commit d627063
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core/createWebWorkerPromise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
}
Expand All @@ -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)
}
Expand Down

0 comments on commit d627063

Please sign in to comment.