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

react-scripts 3.3.0 doesn't work in development mode on IE or edge due to WebSocket constructor #8084

Closed
WieserSoftware opened this issue Dec 5, 2019 · 12 comments · Fixed by #8116
Milestone

Comments

@WieserSoftware
Copy link

When loaded into the browser, it throws a syntax error to the console on this line:

webpackHotDevClient line 60

// Connect to WebpackDevServer via a socket.
var connection = new WebSocket(

I'm guessing this is because the constructor is not supported on edge or IE. Is there a polyfill to work around this?

@justrealmilk

This comment has been minimized.

@esetnik

This comment has been minimized.

@yamilfrich

This comment has been minimized.

@esetnik

This comment has been minimized.

@justrealmilk

This comment has been minimized.

@yamilfrich

This comment has been minimized.

@ianschmitz
Copy link
Contributor

Can you guys confirm that this was caused by the incorrect WS protocol? I'm hoping the fix we've merged in #8079 will fix this.

@ianschmitz ianschmitz added this to the 3.3.1 milestone Dec 6, 2019
@esetnik
Copy link

esetnik commented Dec 6, 2019

@ianschmitz i don’t think #8079 will fix this issue. We accidentally hijacked this issue when ours was really #8075.

@WieserSoftware

This comment has been minimized.

@ianschmitz
Copy link
Contributor

ianschmitz commented Dec 6, 2019

@WieserSoftware
Copy link
Author

WieserSoftware commented Dec 8, 2019

I've finally had time to investigate.
It appears that the url module is only appending // to protocols it deems require it, but it does not list ws or wss in the slashedprotocols map in url.js

So to fix this, that module could be patched, or the url format could be changed to include slashes: true in the object passed.

It turns out that chrome will take a url that looks like ws:localhost:3000/sockjs-node but when the websocket is created, it changes it to ws://localhost:3000/sockjs-node

@Baael
Copy link
Contributor

Baael commented Dec 8, 2019

I've finally had time to investigate.
It appears that the url module is only appending // to protocols it deems require it, but it does not list ws or wss in the slashedprotocols map in url.js

Thank you! Fix to keep monday morning deadline if anyone needs:

./node_modules/react-dev-utils/webpackHotDevClient.js:60 add slashes: true

// Connect to WebpackDevServer via a socket.
var connection = new WebSocket(
  url.format({
    protocol: window.location.protocol === 'https:' ? 'wss' : 'ws',
    hostname: window.location.hostname,
    port: window.location.port,
    // Hardcoded in WebpackDevServer
    pathname: '/sockjs-node',
    slashes: true,
  })
);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants