Closed w1nklr closed 4 months ago
Thanks @t0oF-azpn for reporting this issue and working out a fix!
Would it be possible to write a unit test to ensure we can't get any regressions in the future?
Thanks @t0oF-azpn for reporting this issue and working out a fix!
Would it be possible to write a unit test to ensure we can't get any regressions in the future?
I tried first to add/update the unit tests. But I didn't manage to make it run.
In this particular case, we need to be in browser context. I tried to force to use web workers (var pool = createPool({ workerType: 'web' });
), but this fails at worker creation in ensureWebWorker()
function.
If there is any way to set the test to web browser context, I would take it ;)
OK let's just merge this PR as is, ok? The fix makes sense.
I do think though that referring to worker
in a standalone function is a bit of a tricky case: you're relying on an undocumented global variable exposed by a library. The neat solution would be to create a dedicated worker where you import worker
explicitly.
I'm fine with merging This PR as is ! I don't have the rights to do it, though ;)
👍 I'll merge and publish your PR first half of next week.
I found a moment, just published v9.1.1
containing your fix. Thanks again!
When using worker-pool in a browser environment, worker function registration does not work. Only
pool.exec(<function>)
can be run, but does not handle the on message callbacks.This fix proposes to send the
pool.exec
options to the execution script.Referenced doc: https://github.com/josdejong/workerpool#events Playground: https://codesandbox.io/p/sandbox/workerpool-in-a-react-project-forked-dgjxxc
Possible fix for issue #438