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

SocketIO import on shared worker causes: "Failed to execute 'importScripts' on 'WorkerGlobalScope'" #5160

Open
JoshAvakian opened this issue Aug 7, 2024 · 1 comment
Labels
to triage Waiting to be triaged by a member of the team

Comments

@JoshAvakian
Copy link

JoshAvakian commented Aug 7, 2024

Describe the bug
A clear and concise description of what the bug is.

Using 4.7.5, when running a production build utilizing shared workers, socket.IO import causes a DOMException. Development builds and virtual environment (localhost) do not have this issue

To Reproduce

  1. Create a shared worker within any react app, and import socketIO in the shared worker like so:
import { io } from 'socket.io-client';
  1. In your react app, call this shared worker (can perform any task, the import is what causes the issue)

  2. Run a production build using yarn

When opening the new production build, worker file will not run, and opening the console on the shared worker will look like this:

"Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'https://yourApp/static/js/static/js/3002.2646329c.chunk.js' failed to load."

When removing the socket.io import and re-running the build, the worker will no longer throw this error.

Expected behavior
No importScripts error is thrown, and shared workers can open their own socket session.

Platform:

  • Device: Lenovo ThinkBook 15p
  • OS: Ubuntu

Additional context
Please note that a development build and a local environment will not throw this error in the shared worker. We discovered it only after we ran a production build using yarn

@JoshAvakian JoshAvakian added the to triage Waiting to be triaged by a member of the team label Aug 7, 2024
@JoshAvakian
Copy link
Author

This looks similar to #3809

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to triage Waiting to be triaged by a member of the team
Projects
None yet
Development

No branches or pull requests

1 participant