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

V3.3.0 live reload broken when set hostname to 0.0.0.0:xxxx #1777

Closed
1 of 2 tasks
njugray opened this issue Apr 9, 2019 · 39 comments · Fixed by #1838
Closed
1 of 2 tasks

V3.3.0 live reload broken when set hostname to 0.0.0.0:xxxx #1777

njugray opened this issue Apr 9, 2019 · 39 comments · Fixed by #1838
Assignees

Comments

@njugray
Copy link

njugray commented Apr 9, 2019

  • Operating System: MacOS

  • Node Version: v10.15.0

  • NPM Version: 6.4.`

  • webpack Version: 4.29.6

  • webpack-dev-server Version: 3.3.0

  • This is a bug

  • This is a modification request

Code

port = self.location.port;

When start a node server like 0.0.0.0:8080, and load resources from 0.0.0.0:9000, Port was reset to self.location.port , which actually is 8080.

For Bugs; How can we reproduce the behavior?

  • Start webpack-dev-server and listen at e.g. 0.0.0.0:9000
  • Load resources from another local server like: 0.0.0.0:8080

Expected Behavior

Live reload should listen 0.0.0.0:9000

Actual Behavior

Live reload listen 0.0.0.0:8080

@alexander-akait
Copy link
Member

@njugray Please create minimum reproducible test repo

@njugray
Copy link
Author

njugray commented Apr 10, 2019

@njugray
Copy link
Author

njugray commented Apr 10, 2019

  1. Install dependencies and npm run dev

  2. Visit: http://127.0.0.1:8080/

  3. See network inspect, will get:
    image

@alexander-akait
Copy link
Member

Thanks!

@alexander-akait
Copy link
Member

/cc @hiroppy can you investigate? Don't have time on this right now 😞

@alexander-akait alexander-akait self-assigned this Apr 11, 2019
@ryank311
Copy link

This one also affects us because we run the dev server on a different port than our node server that is serving the page. It would be huge for us if the sockjs host was configurable/override-able, as it would let us do things like run the webpack-dev-server on a different host or in a container separate from our node server.

@alexander-akait
Copy link
Member

Maybe sockHost and sockPort? Now we already support sockPath

@ryank311
Copy link

Yeah, I took a look and if we could set the sockHost and sockPort, that would work for us. Unfortunately with just sockpath, it doesn't give us enough control over the domain. Another alternative would be to utilize the publicPath, publicHost and publicPort that are already part of the config, but either would unblock us from upgrading.

Also, we should probably document the sockHost, sockPort and sockPath as I was only able to reason about them by stepping through the code.

@alexander-akait
Copy link
Member

sockPort PR #1792, yep we will documented this in near future

@alexander-akait
Copy link
Member

/cc @hiroppy i think we do breaking change here 2f7f052 😞

@ryank311
Copy link

I did see the PR and it looks like it would resolve my issue. Is there a reason why this is different from the public host and Port? Afaik there wouldn't be a scenario when those would be different.

@alexander-akait
Copy link
Member

alexander-akait commented Apr 12, 2019

I think it is bug, and should be by default with public host and public port, previously main commiter don't add tests on many features and now we have many weird code and sometimes break something, now we increase tests and in future this problem will be less, sorry

@alexander-akait
Copy link
Member

Any way PR welcome

@phil-lgr

This comment has been minimized.

@alexander-akait

This comment has been minimized.

@knagaitsev
Copy link
Collaborator

@ryank311 sockHost and sockPort would be different from host and port in the case mentioned here where the Dev Server is behind a proxy. The inferring of the port from location.port in that PR is the breaking change here, so it would be beneficial to have options to set it rather than to try and guess the socket host and port.

@zhangyuang
Copy link
Contributor

zhangyuang commented Apr 13, 2019

my pr can fix your problem
and you can also start your app by webpack-dev-server --port 8080 make it get the true port.
because it use location.port if your urlParts.port is undefined
but at this time ,you can't add sockPath in your option,
because here image
if my pr is merge, you can set sockPort by webpack-dev-server --sockPort 8080

@knagaitsev
Copy link
Collaborator

@zhangyuang yes that will fix the immediate issue here. 2 other things that probably need to be done:

  • revert parts of this so it is not default behavior to infer the port from location.port (it will be possible to achieve this behavior manually when sockPort is added)
  • add sockHost so that the dev server can exist on a different host

@zhangyuang
Copy link
Contributor

zhangyuang commented Apr 13, 2019

@zhangyuang yes that will fix the immediate issue here. 2 other things that probably need to be done:

  • revert parts of this so it is not default behavior to infer the port from location.port (it will be possible to achieve this behavior manually when sockPort is added)
  • add sockHost so that the dev server can exist on a different host

you can use host option to use correct host now
image

@alexander-akait
Copy link
Member

alexander-akait commented Apr 13, 2019

@zhangyuang

revert parts of this so it is not default behavior to infer the port from location.port (it will be possible to achieve this behavior manually when sockPort is added)

Can you send a PR?

add sockHost so that the dev server can exist on a different host

Already done

@zhangyuang
Copy link
Contributor

@zhangyuang

revert parts of this so it is not default behavior to infer the port from location.port (it will be possible to achieve this behavior manually when sockPort is added)

Can you send a PR?

add sockHost so that the dev server can exist on a different host

Already done

ok

@zhangyuang
Copy link
Contributor

@zhangyuang

revert parts of this so it is not default behavior to infer the port from location.port (it will be possible to achieve this behavior manually when sockPort is added)

Can you send a PR?

add sockHost so that the dev server can exist on a different host

Already done

already finish,now if you add sockPort, it will be never use location.port
but as I said before,if you add sockPort but don't add sockPath
the hostname expression result is error
i hope you can refactoring previous behavior in the future

@alexander-akait
Copy link
Member

alexander-akait commented Apr 13, 2019

@zhangyuang please revert this, and let's do this in other PR, it is male dirty history and dirty changelog

@alexander-akait
Copy link
Member

/cc @hiroppy i think we need revert 2f7f052, what do you think?

@hiroppy
Copy link
Member

hiroppy commented Apr 16, 2019

@evilebottnawi Yeah, could you revert only client-src/default/index.js because puppeteer is already used?

@alexander-akait
Copy link
Member

@hiroppy yep, some busy in this week, feel free to do this

yunyu950908 referenced this issue in vuejs/vue-cli Apr 23, 2019
@iiroj
Copy link

iiroj commented Apr 23, 2019

It seems this has been fixed in 58d1682#diff-bd664d218d585ff7bd6ceced46bd877aL229, now we're just waiting for a new release.

@knagaitsev
Copy link
Collaborator

add sockHost so that the dev server can exist on a different host

Already done

@evilebottnawi Where is sockHost? I can't find it in the options, and can't find anything suggesting that it has been implemented.

@alexander-akait
Copy link
Member

@Loonride hm no docs?

@knagaitsev
Copy link
Collaborator

@evilebottnawi Yes but also sockHost just does not exist here: https://github.com/webpack/webpack-dev-server/blob/master/lib/options.json. Unless it exists under another name, I don't think it has been implemented

@alexander-akait
Copy link
Member

Yes, it is bug, but it is options only for CLI, you can use this in webpack.config.js

@jonaldinger
Copy link

@evilebottnawi I'm also not understanding how sockHost can be set. sockPort was implemented in PR #1792, but the string "sockHost" does not currently exist anywhere in the master branch of the source code of this repo.

Assuming that /client-src/default/index.js is where the actual socket is being created (via socket(socketUrl, onSocketMsg);), it looks like the hostname portion of the socketUrl is being derived from urlParts, which is derived from either

url.parse(__resourceQuery.substr(1));

or

getCurrentScriptSource();

with no method to override the hostname or infer from other config options. I'm not familiar with the inner workings of this project so it's possible I'm looking in the wrong place, or that the sockHost value could be coming in via __resourceQuery, or that I'm just completely overlooking something. But I'm interested in this feature so thought I would share my observations.

@alexander-akait
Copy link
Member

Oh, yes we don't have sockHost now, i mean sockPath, if somebody needed in sockHost you can send a PR, it is easy

@pedrofurtado
Copy link

@hiroppy In what version this hotfix will be available? 👍

@hiroppy
Copy link
Member

hiroppy commented May 7, 2019

@pedrofurtado This fix will be fixed in the next version and the next version will be released in this week.

@pedrofurtado
Copy link

@hiroppy Thanks for feedback! 🤝

@ranand
Copy link

ranand commented May 14, 2019

hi @hiroppy - thanks for all the awesome work in maintaining this. any chance that a fix (new release) will be available this week, please?

@alexander-akait
Copy link
Member

Yes, release will be on this week

@Krzysiek555
Copy link

[Vue.js] FYI @vue/cli-service in version 3.7.0 uses webpack-dev-server in version 3.3.x
To benefit from the merged PR you will have to bump @vue/cli-service to 3.8.4 which has the webpack-dev-server in 3.4.1 Cheers!

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

Successfully merging a pull request may close this issue.