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

Prerendering throws errors when prerendering a worker #853

Open
1 of 3 tasks
marvinhagemeister opened this issue Sep 6, 2021 · 1 comment
Open
1 of 3 tasks

Prerendering throws errors when prerendering a worker #853

marvinhagemeister opened this issue Sep 6, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@marvinhagemeister
Copy link
Member

Describe the bug
Due to environmental API differences between Web Workers and Node's Worker Threads there are a bunch of undefined global variables that the Web Worker API expects. Things like global Worker in non-worker scripts/modules, global self/addEventListener inside instantiated workers etc.

To Reproduce
Prerender a worker.

Expected behavior
No error.

Bug occurs with:

  • wmr or wmr start (development)
  • wmr build (production) + --prerender
  • wmr serve
@marvinhagemeister marvinhagemeister added the bug Something isn't working label Sep 6, 2021
@developit
Copy link
Member

developit commented Sep 6, 2021

We could probably inject self.Worker as a global and point it at web-worker, like we do for location:

globalThis.self = /** @type {any} */ (globalThis);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants