Expected behaviour
If a port is changed in the passed configuration before server start (e.g. if EADDRINUSE is thrown for a specified port, the next available is used), it should be respected by server middleware.
Actual behaviour
Middleware use a port that was initially passed in the configuration.
Environment Details
- Karma version (output of
karma --version): reproduced in 1.7.1, but should be also actual for 2.0.2
- Relevant part of your
karma.config.js file: proxy middleware can be used as an example
proxies: {
'/img/': '/base/test/images/'
},
port: <specify already used port>
Steps to reproduce the behaviour
- Run karma instance (
karma start) with already used port – in other words you have to raise EADDRINUSE error in
|
if (e.code === 'EADDRINUSE') { |
It can be reproduced by running 2 or more karma instances that use the same port (e.g. 9876)
- You have to see Karma warning:
WARN [karma]: Port 9876 in use
and a new port that Karma uses: INFO [karma]: Karma <v> server started at http://0.0.0.0:9877/

- Try to load any resources that match proxy rules.
- Resources are proxied to the initial port
9876 instead of changed 9877.
Expected behaviour
If a port is changed in the passed configuration before server start (e.g. if
EADDRINUSEis thrown for a specified port, the next available is used), it should be respected by server middleware.Actual behaviour
Middleware use a port that was initially passed in the configuration.
Environment Details
karma --version): reproduced in 1.7.1, but should be also actual for 2.0.2karma.config.jsfile: proxy middleware can be used as an exampleSteps to reproduce the behaviour
karma start) with already used port – in other words you have to raiseEADDRINUSEerror inkarma/lib/server.js
Line 186 in 667b47e
9876)WARN [karma]: Port 9876 in useand a new port that Karma uses:
INFO [karma]: Karma <v> server started at http://0.0.0.0:9877/9876instead of changed9877.