josdejong / workerpool

Offload tasks to a pool of workers on node.js and in the browser
Apache License 2.0
2.06k stars 147 forks source link

Electron use throw Error #319

Closed yoonasy closed 3 years ago

yoonasy commented 3 years ago
    "electron": "6.1.12",
    "electron-download": "^4.1.1",
    "electron-log": "^4.3.5",
    "electron-updater": "^4.3.9",
    "vue-cli-plugin-electron-builder": "~1.4.6",

    "workerpool": "^6.1.5"

image

internal/worker.js:105 Uncaught (in promise) Error: The V8 platform used by this instance of Node does not support creating Workers
    at new Worker (internal/worker.js:105)
    at setupWorkerThreadWorker (workerpool.js:886)
    at setupWorker (workerpool.js:859)
    at new WorkerHandler (workerpool.js:976)
    at Pool._createWorkerHandler (workerpool.js:409)
    at Pool._getWorker (workerpool.js:286)
    at Pool._next (workerpool.js:232)
    at Pool.exec (workerpool.js:171)
    at Pool.exec (workerpool.js:176)
    at eval (index.js:551)
yoonasy commented 3 years ago

node: v12.21.0

npm: 7.21.1

yoonasy commented 3 years ago
const workerpool = require('workerpool');
const pool = workerpool.pool();

pool.exec(() => {}, []))

image

Got an error

josdejong commented 3 years ago

You can try to configure { workerType: 'process' } , looks like your version of nodejs doesn't support worker theads.

yoonasy commented 3 years ago

@josdejong
Thank you for your answer, but it still doesn't work. image

josdejong commented 3 years ago

The option workerType needs to be passed when creating pool instead of when calling pool.exec, see docs: https://github.com/josdejong/workerpool#pool

yoonasy commented 3 years ago

@josdejong Thank you very much.

image