Skip to content

Commit

Permalink
Merge pull request #1794 from finos/fix-worker-file-protocol
Browse files Browse the repository at this point in the history
Allow attempt to create workers from file protocol for e.g. electron
  • Loading branch information
texodus authored May 1, 2022
2 parents b726e29 + 1b7a785 commit 65b01c5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/perspective-build/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,15 @@ exports.WorkerPlugin = function WorkerPlugin(inline) {
export const initialize = async function () {
const code = await code_promise;
if (window.location.protocol.startsWith("file")) {
return run_single_threaded(code, "file:// protocol does not support Web Workers");
console.warn(code, "file:// protocol does not support Web Workers");
}
try {
const blob = new Blob([code], {type: 'application/javascript'});
const url = URL.createObjectURL(blob);
return new Worker(url, {type: "module"});
} catch (e) {
console.warn("Failed to instantiate worker, falling back to single-threaded runtime", e);
return run_single_threaded(code, e);
}
};
Expand Down

0 comments on commit 65b01c5

Please sign in to comment.