josdejong / workerpool

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

DomException when passing parameters to worker (Vue3, webpack5) #449

Closed Corey-J closed 2 months ago

Corey-J commented 2 months ago

Hi, I'm just setting up a worker in Vue to offload some calculations to and upon setting up data i am struggling to pass parameters into the exec method.

I have verified workers are running on methods not being passed parameters, but the below errors occurs when calling exec with any parameters.

Any help would be appreciated!

Worker.ts Definition image

Calling Worker image

Exception image

edit: When using the proxy example and calling the method this is successful image

josdejong commented 2 months ago

How can we reproduce your issue? Can you create a minimal demo on https://stackblitz.com/ for example?

Corey-J commented 2 months ago

This will take some time to transpose the setup of the project, and may not be possible in a cloud sandbox - but i shall see what can be done. The project uses Razor to render a Vue 3 application compiled via webpack with quite a fair bit of config

Using a standard web worker.postMessage being able to send the same object is functional.

@Provide()
worker!: Worker

.....

const WorkerURL = new WorkerUrl(new URL('../worker.ts', import.meta.url));
this.worker = new Worker(WorkerURL.toString());

let sendObject = { complexObj1: complexObj1, complexObj2: complexObj1};

this.worker.postMessage(JSON.stringify(sendObject));
josdejong commented 2 months ago

Thanks. Maybe it helps to copy your existing project and strip it down to the core to figure out what part is relevant for the issue.

josdejong commented 2 months ago

Closing due to a lack of response. Please reopen if still relevant.