Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

worker starting further workers #12

Open
gerdstolpmann opened this issue Jul 30, 2020 · 2 comments
Open

worker starting further workers #12

gerdstolpmann opened this issue Jul 30, 2020 · 2 comments

Comments

@gerdstolpmann
Copy link

I recently ran into a bad trap: I had another require('web-worker') in the code of the child and not only in the parent. This doesn't work, because the workerThread function is then executed again. The symptom is that messages are received twice in the worker.

This was hard to figure out. Note that this is not really a user's error, because a web worker is normally allowed to start another web worker. So it makes sense in general. (In my code, I could simply comment the bad require out, though.)

I guess that you need to split node.js into two files for this, because the main/worker dichotomy doesn't work anymore when workers can start workers.

@developit
Copy link
Owner

Interesting. There's probably a way to do it without the split by checking if initData was set. Good catch.

@dakman
Copy link

dakman commented May 31, 2021

Would be awesome if this package supported worker recursion ... so used to the native MDN webworker syntax .. for now I'll have to use threadbox or thread.js or something :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants