Skip to content

v4: client web socket port incorrect if using findPort instead of hard-coded port. #2873

@jolyndenning

Description

@jolyndenning
  • Operating System: osx

  • Node Version: 14.15.0

  • NPM Version: 6.14.8

  • webpack Version: 5.8.0

  • webpack-dev-server Version: 4.0.0-beta.0

  • Browser: Chrome

  • This is a bug

  • This is a modification request

Code

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 cross origin.

https://github.com/joeldenning/wds-port-bug

Expected Behavior

webpack-dev-server client code should set up the web socket connection on the port found by webpack-dev-server's findPort function.

Actual Behavior

webpack-dev-server client code defaults to establishing a web socket connection on the port of the origin server, instead of the port of the webpack-dev-server.

Note that in webpack-dev-server@3, this worked.

For Bugs; How can we reproduce the behavior?

https://github.com/joeldenning/wds-port-bug

For Features; What is the motivation and/or use-case for the feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions