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

No workerHelpers.worker.js generated & ReferenceError: Window is not defined #16

Open
laurelch opened this issue Oct 16, 2024 · 5 comments

Comments

@laurelch
Copy link

laurelch commented Oct 16, 2024

Initially, I was receiving the following error

Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

from the .../pkg/snippets/wasm-bindgen-rayon-[hash]/src/workerHelpers.worker.js?worker_file&type=module in the browser.

After investigating, I realized there is no workerHelpers.worker.js generated in the /pkg/snippets/wasm-bindgen-rayon-[hash]/src/ of my project. It only contained workerHelpers.js.

I attempted to compile both the demo/ and test/ directories inside the wasm-bindgen-rayon workspace, and in those cases, the workerHelpers.worker.js file was generated successfully. However, when I tried to create a standalone project, the file was not generated, even when I just copied the test/ directory outside of the workspace (and updated its dependencies).

The command I was using is $ wasm-pack build --target web, and I did not encounter any errors.

Thank you so much for any guidance!

@Jonarod
Copy link

Jonarod commented Oct 17, 2024

+1 Exactly in the same situation...

@Jonarod
Copy link

Jonarod commented Oct 17, 2024

Got around the error by copy-pasting this file:

https://github.com/RReverser/wasm-bindgen-rayon/blob/main/src/workerHelpers.worker.js

But I am not able to get passed await initThreadPool(navigator.hardwareConcurrency); which never resolves...

@laurelch
Copy link
Author

laurelch commented Oct 17, 2024

Yes, seems that copy-pasting the file helped (partially), but I'm still getting both the following errors in my own project

Uncaught (in promise) RangeError: Maximum call stack size exceeded

&

ReferenceError: Window is not defined

I was able to reproduce the same "ReferenceError: Window is not defined error" with demo when using Vite. This error was fixed by closing and reopening the tab for demo, but this error in my own project persisted even with closing and reopening.


I was able to avoid the "ReferenceError: Window is not defined" in my own project by closing the DevTools window and refreshing.

@laurelch laurelch changed the title No workerHelpers.worker.js generated in pkg/snippets/wasm-bindgen-rayon-[hash]/src No workerHelpers.worker.js generated & ReferenceError: Window is not defined Oct 17, 2024
@laurelch laurelch changed the title No workerHelpers.worker.js generated & ReferenceError: Window is not defined No workerHelpers.worker.js generated & Maximum call stack size exceeded Oct 17, 2024
@laurelch laurelch changed the title No workerHelpers.worker.js generated & Maximum call stack size exceeded No workerHelpers.worker.js generated & ReferenceError: Window is not defined Oct 17, 2024
@aW4KeNiNG
Copy link

Same problem here

@TheFrozenFire
Copy link

rustwasm/wasm-bindgen#4233 (comment)

Revert to wasm-bindgen 0.2.93 to fix. The current latest version 0.2.95 has a regression which breaks link_to!, as used in

wasm_bindgen::link_to!(module = "/src/workerHelpers.worker.js");

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

4 participants