question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

webpack-dev-server 4.0.0-beta.3 causes react-refresh-webpack-plugin to crash

See original GitHub issue

Not sure if it’s a bug, or even if it’s on your side, but just a heads-up, and hopefully some info that could come in handy if people stumble upon the same issue as me.

Updating webpack-dev-server from 4.0.0-beta.2 to 4.0.0-beta.3 caused several of my apps to crash because of react-refresh-webpack-plugin 0.4.3 with the following error:

Uncaught DOMException: Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. 'https' is not allowed.
    at new WebsocketClient (webpack:///node_modules/webpack-dev-server/client/clients/WebsocketClient.js?:39:20)
    at Module.initWDSSocket (webpack:///node_modules/@pmmmwh/react-refresh-webpack-plugin/sockets/WDSSocket.js?:24:24)
    at setupOverlay (webpack:///node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ErrorOverlayEntry.js?:86:32)
    at runWithPatchedUrl (webpack:///node_modules/@pmmmwh/react-refresh-webpack-plugin/client/utils/patchUrl.js?:36:3)
    at eval (webpack:///node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ErrorOverlayEntry.js?:82:62)
    at Module./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ErrorOverlayEntry.js?sockHost=0.0.0.0&sockPort=3001&sockProtocol=https (https://localhost:3001/vendors-node_modules_pmmmwh_react-refresh-webpack-plugin_client_ErrorOverlayEntry_js_sockHost-9da5dc.b56e57f2.js:18:1)

Updating react-refresh-webpack-plugin to 0.5.0-beta.7 (to get #242) and configuring it like so:

    new ReactRefreshWebpackPlugin({
+      overlay: {
+        sockProtocol: 'wss',
+        sockHost: 'localhost',
+      },
    }),

causes the app to load again without any errors.

Hardcoding sockHost, however, had negative consequences, because now I couldn’t use react-refresh on other hosts e.g. for mobile testing. If I didn’t hardcode sockHost it was resolved to 0.0.0.0 which I have set in devServer.host.

Finally, removing devServer.host altogether and removing sockHost from ReactRefreshWebpackPlugin options cause it all to work again, both locally and remotely.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
pmmmwhcommented, May 10, 2021

I don’t think you need to hard code sockHost? I believe it was just the protocol that was broken.

I plan to fix this issue (because the default socket have been changed to ws instead of sockjs) by adding a compatibility layer so in the next beta you shouldn’t have to do anything on that.

0reactions
pmmmwhcommented, Jul 6, 2021

How do I upgrade to Beta?

Use @pmmmwh/react-refresh-webpack-plugin@next (0.5.0-rc.1) instead of 0.4.3.

Read more comments on GitHub >

github_iconTop Results From Across the Web

webpack-dev-server 4.0.0-beta.3 causes react-refresh ...
Updating webpack-dev-server from 4.0.0-beta.2 to 4.0.0-beta.3 caused several of my apps to crash because of react-refresh-webpack-plugin ...
Read more >
the request of a dependency is an expression when ... - GitHub
Critial Dependency: the request of a dependency is an expression when upgrading to 4.0.0-beta.3 from beta.2 #3361. ZachMayry opened this issue ...
Read more >
Webpack 5 Full Project Setup - YouTube
We are going for the big haul on this one. We'll start out creating a new Webpack 5 project, putting it on Github,...
Read more >
Webpack Dev Server Config - contentBase not working in ...
When I upgrade webpack to 4.0.0-beta.3 and run npx webpack serve I get this error: [webpack-cli] Invalid configuration object. Object has been initialized ......
Read more >
@pmmmwh/react-refresh-webpack-plugin - npm
Start using @pmmmwh/react-refresh-webpack-plugin in your project by ... Using custom renderers (e.g. react-three-fiber , react-pdf , ink ).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found