I have an electron app where I am trying to push some CPU intensive tasks to a worker thread. This works well when I start the app using npm start
, but after packing the app (with electron-packager with --asar) the worker thread appears to stop working. I am loading the worker thread like so:
const workerThread = new SharedWorker(path.join(__dirname, "JS/JS_MainWindow/worker.js"));
I am very confused about what could be causing this, but could it maybe be that the appl is being packaged into an ASAR folder? I am very confident I have the path correct for loading the worker file as I am loading several other images with the sameish path.
console.log(path.join(__dirname, "JS/JS_MainWindow/worker.js"))
and inspect the path after packing? (enable developer tools to follow) – PottyC:\FOD\FOD-JS\fodGUI-win32-x64\resources\app.asar\src\JS\JS_MainWindow\worker.js
– Swayfs.existsSync(path.join(__dirname, "JS/JS_MainWindow/worker.js"))
returnstrue
even after packaging. So the file is definitely there and its definitely at least seeable by the app post packaging. – Sway