-
Notifications
You must be signed in to change notification settings - Fork 17k
Description
Preflight Checklist
I have read the Contributing Guidelines for this project.
I agree to follow the Code of Conduct that this project adheres to.
I have searched the issue tracker for a feature request that matches the one I want to file, without success.
Electron Version
12.0.0
What operating system are you using?
macOS
Operating System Version
macOS Big Sur 11.2.3
What arch are you using?
arm64 (including Apple Silicon)
Last Known Working Electron version
No response
Expected Behavior
A renderer should be able to new SharedWorker() or new Worker() with a URL pointing to a script inside the asar.
Actual Behavior
A regular Worker script can be loaded from the asar, but a SharedWorker can not. A SharedWorker works properly when running via electron .webpack, but fails to load when packaged into an app with .asar.
Limited error information is available, because the worker doesn't appear in webContents.getAllSharedWorkers() so dev tools cannot be opened (possibly related: #25512). The worker's onerror event is triggered with an error, but the error contains little information. Here is an example screenshot where I reproduced the issue in the developer console. The Network tab doesn't include any info about the worker script we're trying to load.
On the other hand, I am able to fetch the URL directly. So if I run this in the dev console:
const w = new SharedWorker(URL.createObjectURL(await (await fetch("...app.asar/...")).blob()));
w.onerror = (e) => console.log("worker error", e);then the worker does load and I can open its dev tools (although it soon encounters an error when the webpack-bundled worker script tries to use importScripts with a relative URL that doesn't work on my blob: url.)
Testcase Gist URL
I found a similar issue discussed on Stack Overflow, but it seems these people are trying to use a SharedWorker in node, but I'm trying to use it in the renderer.
