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

In default dune builds, the brr library raises an exception in web workers #40

Closed
andrewray opened this issue Nov 19, 2022 · 4 comments
Closed
Labels
bug Something isn't working

Comments

@andrewray
Copy link

I think without aggressive dead code elimination (which is the case with --profile=dev dune builds) there is something that accesses the global document object, and this causes an exception when the code is run in a web worker context.

With --profile=release things seem to be OK.

Maybe worth some comment in the documentation, though it would be really nice if things worked smoothly in dev mode also.

@andrewray andrewray changed the title In default dune builds, the brr library raises and exception in web workers In default dune builds, the brr library raises an exception in web workers Nov 19, 2022
@dbuenzli dbuenzli added the bug Something isn't working label Nov 19, 2022
@dbuenzli
Copy link
Owner

Yes ! It was fixed in 655a3d6. I will make a release anytime soon.

@dbuenzli
Copy link
Owner

(if you can confirm that opam pin brr --dev works for you, it's even better)

@andrewray
Copy link
Author

Yup, it works by pinning the dev version. Thanks!

@dbuenzli
Copy link
Owner

Excellent, thanks for the confirmation.

Maybe worth some comment in the documentation, though it would be really nice if things worked smoothly in dev mode also.

It's not only about dev mode. I like to be able to have a single js artefact and simply:

let () = if Brr_webworkers.Worker.ami () then worker () else main ()

(if you write the the artefact in the html file and perform terrible circonvolutions it's even possible to make it work over the file:// protocol).

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