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

fix: transfer from worker fixed #455

Closed LeonidPolukhin closed 2 months ago

josdejong commented 2 months ago

Thanks for debugging and fixing this issue Leonid.

Can you add a unit test too, to prevent future regressions?

w1nklr commented 2 months ago

Hi @josdejong I'm afraid it's the same problem than https://github.com/josdejong/workerpool/pull/439#issuecomment-2034032764.

Again, if there is a way to do unit tests in browser env, I would be more than happy to (learn the way to do and) to implement the test ! But for now, we're clueless with @LeonidPolukhin ...

josdejong commented 2 months ago

Ok makes sense. Let's not try to write an automated test then.

Do you have a minimal browser example that I can test manually to verify the solution?

LeonidPolukhin commented 2 months ago

Ok makes sense. Let's not try to write an automated test then.

Do you have a minimal browser example that I can test manually to verify the solution?

I could add one more example in, for instance, examples/webpack5 or extend the existing one. Which variant would you prefer?

w1nklr commented 2 months ago

I'll check with @LeonidPolukhin

I saw there is an example with webpack5 (examples/webpack5). We might be able to enrich this example...

LeonidPolukhin commented 2 months ago

I'll check with @LeonidPolukhin

I saw there is an example with webpack5 (examples/webpack5). We might be able to enrich this example...

Extended the example in webpack 5. Worker creates an array of the requested size and transfers it back to the main thread using workerEmit. After that it returns boolean value indicating whether the array buffer is detached. With the current version of workerpool the example shows that arrays are cloned but with the fix applied they are transferred.

josdejong commented 2 months ago

Thanks, I tried it out and indeed it works like expected 👍

josdejong commented 2 months ago

The fix is published now in v9.1.3, thanks again!