-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Regression: web socket connection fails with @webpack-cli/serve@1.4.0 when using findPort #3351
Comments
Was reading dev-server code and it seems we're setting a port in server - webpack-dev-server/lib/Server.js Line 774 in 297a649
And calc for port is taking into account the port we found -
But it's not being passed here, we're just passing default options -
I think setting options.client.port in the server should fix this? Happy to PR if this is the right direction /cc @alexander-akait |
Actually, I'm unable to repro this in a blank config in your old repo with updated packages @joeldenning, could you possibly create a branch in the repo for this bug? Thanks! |
Thanks @anshumanv for looking into this. I've pushed to https://github.com/joeldenning/wds-port-bug/tree/webpack-cli-issue-2696 (the |
oh, we endlessly rush between attempts to solve problems with proxied server and non proxied, after fixing bug for non proxied we get a new bug for proxied and versa vice. Honestly if I write this server from scratch I say: always set The problem - we trying to convert dev server to plugin, so we need inject entry with options before listen, but we don't know port before listen... Also here were other problems between host/port/path of websocket server and client options to websocket client. No ideas how to solve them together. It will blow my head soon. |
Let's keep open before stable release, maybe I found way... if not I will document it and mask as breaking change. For me using |
Also it will allow us to remove the |
👍🏿 that option seems sensible to me - thanks for investigating it |
Found the way how we will fix it without breaking a plugin support, I will try to fix this in near future to the next release |
Describe the bug
When the port is left unspecified (both in CLI args and in webpack config), webpack-dev-server finds a port, defaulting to 8080 when possible. However, the webpack-dev-server client code is not aware of which port was chosen, and the resource query for setting up the web socket is unaware of that port. This causes the webpack-dev-server client code to attempt to connect to the wrong port when a bundle is loaded on a different port from the host html file
This bug was initially reported in #2873, and also in #2142 for older versions of webpack. I fixed it both times, in webpack/webpack-cli#2147 and #2143
@webpack-cli/serve@1.4.0
appears to have caused a regression, where the bug is back. I think it is because of webpack/webpack-cli#2648, although haven't confirmed if it's that PR or not. From the code in webpack/webpack-cli#2648 it seems very likely to be related.The regression was initially brought to my attention in single-spa/create-single-spa#293 by @PieterBoeren.
What is the current behavior?
When you run
webpack-dev-server
without a port, it finds a port but the client code doesn't know which port was found and therefore does not attempt a web socket connection to the correct port.To Reproduce
Steps to reproduce the behavior:
I can create a Github repo for this if needed. I created https://github.com/joeldenning/wds-port-bug for an older version of webpack-cli and can create a new one for this newer version, if necessary
Expected behavior
The port found by
findPort
should be passed to the client code as a__resourceQuery
. The client should connect to the server on the correct portScreenshots
(should be connecting to port 8080, but is not)
Please paste the results of
webpack-cli info
here, and mention other relevant informationAdditional context
The text was updated successfully, but these errors were encountered: