Skip to content

EADDRINUSE error leads to improper port usage by server middleware #3011

@sergei-startsev

Description

@sergei-startsev

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

  1. 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)
  2. 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/

image

  1. Try to load any resources that match proxy rules.
  2. Resources are proxied to the initial port 9876 instead of changed 9877.

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