Skip to content

Request the running port number using port 0 #998

@gmschouten

Description

@gmschouten

Do you want to request a feature or report a bug?
feature

What is the current behavior?

server.listen(0, '127.0.0.1', () => {
 // port will automaticly assign to a free port.
});

What is the expected behavior?

server.listen(0, '127.0.0.1', () => {});

server.once('listening', () => {
   // while running we want to request the used port number.
   const port = server.address().port;
});

If this is a feature request, what is motivation or use case for changing the behavior?
I use webpack-dev-server to serve my application for browser-test. I want webpack to use a free port and after serving to tell my browser-test where to find the test-pages.

Please mention your webpack and Operating System version.
webpack: 3.3.0
webpack-dev-server: 2.5.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions