Skip to content

API Server is always listening, even if disabled #5474

@mvantellingen

Description

@mvantellingen

Describe the bug

For a while now I get a popup in MacOS that node wants to listen to incoming network connections. Diving into this now with NODE_DEBUG=net it seems vitest is opening a server:

NET 39096: setupListenHandle null 24678 4 0 undefined
NET 39096: setupListenHandle: create a handle
NET 39096: bind to ::

Setting api: false in the config doesn't work, I can modify these values however. When setting the following in my vitest config:

api: {
  port: 36321,
  host: "127.0.0.1",
}

And the NODE_DEBUG=net output is:

NET 39562: setupListenHandle 127.0.0.1 36321 4 false undefined
NET 39562: setupListenHandle: create a handle
NET 39562: bind to 127.0.0.1

 RUN  v1.4.0 /Users/mvantellingen/foobar
      API started at http://127.0.0.1:36321/

So explicitly setting the API config modifies the listen port, and actually shows that the API is starting.

Reproduction

Run vitest using NODE_DEBUG=net and look for the output

System Info

System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 1.13 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.7.1 - /opt/homebrew/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 10.5.0 - /opt/homebrew/bin/npm
    pnpm: 8.15.5 - /opt/homebrew/bin/pnpm
    bun: 1.1.0 - /opt/homebrew/bin/bun
  Browsers:
    Chrome: xx
    Edge: xx
    Safari: xx
  npmPackages:
    @vitest/coverage-v8: 1.4.0 => 1.4.0
    vitest: 1.4.0 => 1.4.0

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions