Skip to content
This repository has been archived by the owner on Sep 9, 2021. It is now read-only.

Commit

Permalink
fix: memory leak for inline workers (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Jul 10, 2020
1 parent f03498d commit f729e34
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/workers/InlineWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ module.exports = function inlineWorker(content, url, workerType) {
blob = new Blob([content]);
}

return CreateWorker(URL.createObjectURL(blob), workerType);
var objectURL = URL.createObjectURL(blob);
var worker = CreateWorker(objectURL, workerType);

URL.revokeObjectURL(objectURL);

return worker;
} catch (e) {
return CreateWorker(
'data:application/javascript,' + encodeURIComponent(content),
Expand Down
3 changes: 2 additions & 1 deletion src/workers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const getWorker = (file, content, options) => {
)}, ${fallbackWorkerPath}, ${options.workerType})`;
}

let worker = 'Worker';
let worker;

switch (options.workerType) {
case 'SharedWorker':
worker = 'SharedWorker';
Expand Down

0 comments on commit f729e34

Please sign in to comment.