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

Error when initializing Child Workers #99

Open
kevinfmoody opened this issue Jun 18, 2020 · 2 comments · May be fixed by #113
Open

Error when initializing Child Workers #99

kevinfmoody opened this issue Jun 18, 2020 · 2 comments · May be fixed by #113

Comments

@kevinfmoody
Copy link

I tried initializing child web workers from a parent worker, and it seems to work well with the exception of the following error being thrown:

rpc-wrapper.js:20 Uncaught ReferenceError: document is not defined
    at Worker.<anonymous> (rpc-wrapper.js:20)

Digging in, it seems like its part of building up the ready event, although document is not in scope in the context of a WebWorker.

let evt = document.createEvent('Event');
evt.initEvent(d.method, false, false);
evt.data = d.params;
worker.dispatchEvent(evt);

What is the purpose of the ready event? Is there a way to build the event in a WebWorker-safe manner? I've looked into new Event, but that's not IE compatible.

@bigbug
Copy link

bigbug commented Dec 23, 2020

I've got the same problem.

@developit
Copy link
Owner

developit commented Jan 9, 2021

You can disable the ready event using the ready:false option.

This is used for the ready event, but can't be disabled. I've opened #113 with a fix.

developit added a commit that referenced this issue Jan 9, 2021
This should fix #99, and uses the newer Event API where supported (including workers).
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

Successfully merging a pull request may close this issue.

3 participants