-
-
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
Use location.port when location.hostname is used to infer HMR socket URL #1664
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, please add tests
@evilebottnawi How are you testing the logic of the client code? I looked for it but couldn't find it in any of the tests. I guess webdriver is the right solution here but I didn't want to add too much overhead to your current tests. Guide me on how you recommend to do it and I'll be glad to add it. |
@evilebottnawi as I understand those tests are checking that the socket and the server are available, but it is not testing the client code that will be executed on the browser's end (more precisely testing the code in https://github.com/webpack/webpack-dev-server/blob/master/client-src/default/index.js). Any suggestions on how to test it without adding the overhead of webdriver?
|
Codecov Report
@@ Coverage Diff @@
## master #1664 +/- ##
=======================================
Coverage 83.76% 83.76%
=======================================
Files 8 8
Lines 536 536
Branches 161 161
=======================================
Hits 449 449
Misses 70 70
Partials 17 17 Continue to review full report at Codecov.
|
@evilebottnawi @hiroppy I added some e2e tests using I created a new Also the Let me know what you think. |
41222a3
to
7192e8c
Compare
4715786
to
688f1af
Compare
Looks good! Ready to merge? |
@evilebottnawi it's ready but for some weird reason the test keeps failing in node 6. The proxy I use fails with a EADDRNOTAVAIL error. I've been trying to repro in a container with node 6.16.0 (same version Appveyor uses), but it works just fine and the test passes without problems. Any idea why this could be happening? |
Maybe something doesn't handle (like errors) or something starts early then tests |
Oh, no ideas |
Something wrong with CI 😕 |
@evilebottnawi I'm still trying to figure out why the proxy fails to connect to the devserver on the appveyor Windows environment for node 6 when the host is 0.0.0.0. I tried to launch a local instance of the appveyor env in local to repro the issue and try to debug with no luck... |
d691605
to
9eb19e1
Compare
@evilebottnawi @hiroppy, it is now ready to merge. Apparently, win32/node 6 has issues establishing a connection to With this PR you can now use the |
Sorry for the late reply. Thank you for creating e2e environment. |
@hiroppy in the test code? sure! I just thought since it should be in an isolated environment it wouldn't matter. I'll just set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if ci is green
/cc @evilebottnawi PTAL;) |
poll: true, | ||
}, | ||
}; | ||
addEntries(config, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/cc @rlamana Looks we catch bug, when we use API
, hot plugin should be added too, can you create issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assumed that it was the API expected behavior, so I didn't think it was a bug. It all makes sense now. I will create the issue then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created issue #1703.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work! Let's create issue about note above and we can merge
@rlamana @evilebottnawi This PR, in version 3.3.0, breaks the use of webpack-dev-server with Rails webpacker gem, inside Docker containers. We used to configure rails app to execute in 0.0.0.0:3000 (from container "A"), and webpack-dev-server in 0.0.0.0:3035 (from container "B"). So, the socket URL must be "0.0.0.0:3035". But, with this version, the socket URL is generated as "0.0.0.0:3000" (same port of Rails app, instead of 3035). |
The version 3.2.1 does not have problem with it 👍 |
This change also broke my setup. I have a static assets server on port 3000 that refers to the webpack-dev-server build on port 8080. Now it is looking for the websocket on port 3000 instead of 8080. This worked fine in 3.2.1. |
@pedrofurtado @nick, so as I understand you are not using the dev-server to actually serve your files, but just using it for the hot reload capability? https://github.com/webpack-contrib/webpack-hot-middleware actually allows you to add hot reloading into an existing server. |
I wonder if |
This change broke our tools too. We have multiple sites proxied to a single domain with different paths. The old behavior was to get the port the actual Webpack dev server, rather than the one after proxied. Now the port changed and it's very tricky works to update the rest parts of the toolchains. |
Thanks for feedback, @rlamana ! Firstly, thanks for you work in maintainance of webpack-dev-server! Actually, I use webpack-dev-server for serve static files and hot replacement. For this, we here use the Webpacker gem (Integration between Webpack and Rails -> https://github.com/rails/webpacker ), that provides the two features mentioned (serving static files and hot replacement). Our setup is Rails application running in localhost:3000, and webpack-dev-server (and its socket) running in localhost:3035 My scenario and scenario of @nick are similar 👍 |
It was fixed, please test with latest version |
@evilebottnawi Thanks! I will test here. Doubt: The latest version is the 3.3.0 (re-released) or the branch master? |
@pedrofurtado |
@evilebottnawi Ok, thank you! |
@evilebottnawi @rlamana Even in The workaround, for me, is to lock in version |
@pedrofurtado Please submit a reproducable repo. |
Broke my setup too (similar to #1664 (comment).). |
also broke my setup, this fix is a breaking change, maybe revisit it? |
yep 😞 we have |
This broke my setup as well. I have an HTML page that references two bundles. Each of them is served from a different WDS instance, running on a different port. |
PR welcome to revert |
Motivation / Use-Case
On a externally exposed dev server (using host 0.0.0.0), HMR client code builds the socket URL using
location.hostname
but uses the port set in server's configuration. In a more complex and layered architecture, since the browser is at the very end of it, the proper way to infer socket's URL (as exposed and proxied by dev server in.../sockjs-node/info?t=XX
) is to also uselocation.port
along with thelocation.hostname
.More and more we see the scenario where the dev server is used in a cloud-based development environment or an architecture with some sort of proxy in front of it.
0.0.0.0
and port9000
and a proxy exposing it inhttp://dev.mydomain.com
(default port 80).http://dev.mydomain.com/sockjs-node/info?t=XX
(default port 80).http://dev.mydomain.com:9000/sockjs-node/info?t=XX
(wrong port 9000).More details in issue: #1663
Breaking Changes
No.
Those who exposed also that wrong port in their proxies as a way around the issue can now remove that configuration.