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

Cannot init a headless Program #23

Open
mingan opened this issue Feb 20, 2019 · 3 comments
Open

Cannot init a headless Program #23

mingan opened this issue Feb 20, 2019 · 3 comments

Comments

@mingan
Copy link

mingan commented Feb 20, 2019

When the library gets used on top of a SharedWorker implemented as a worker program, the wrapping init function fails because document does not exist in the context of the worker.

The failing line in my case is hmr.js#L174 but L170 is going to have the same problem.

Adding a simple guard if (typeof document !== 'undefined') seems to solve the problem at least for me.

@klazuka
Copy link
Owner

klazuka commented Feb 20, 2019

I've never used the service worker api before. If you could post a simple demo app as a gist, I'd be happy to fix the bug.

@mingan
Copy link
Author

mingan commented Feb 21, 2019

Demo here https://github.com/mingan/elm-hot-issue-demo.

The expected behaviour is to see log output (current time every 3 seconds) from the shared worker.

I kicked it off from a starter repo and apart from adding a shared worker loader, I had to downgrade Webpack to version 3 to replicate the issue. V4 ended up with a different error which seems unrelated to this project (the injected HMR code references window directly).

@klazuka
Copy link
Owner

klazuka commented Feb 21, 2019

thanks!

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

2 participants