Skip to content

server.close() in JavaScript API hangs forever #23143

Description

@nicomouss

Describe the bug

From Vite 8.1.4 onward, server.close() can hang forever and never resolve.

Which means that using Vite JavaScript API in Vitest leads to tests timing-out because of that.

Reproduction

https://github.com/nicomouss/Vite-JavascriptAPI-server-close-hanging

Steps to reproduce

The linked repo implements a Vitest test reproducing the error.

Please follow the instructions given in the repo.

The test fails because of the server.close() instruction:

onTestFinished(async () => {
  await server.close(); // This never resolves, leading to the test timing out
});

The issue has been introduced from Vite 8.1.4.
Everything works fine for versions 8.1.3 and below.

System Info

System:
    OS: macOS 15.7.3
    CPU: (8) arm64 Apple M3
    Memory: 2.43 GB / 16.00 GB
  Binaries:
    Node: 24.17.0
    pnpm: 11.8.0
  npmPackages:
    vite: ^8.1.4 => 8.1.4

Used Package Manager

pnpm

Logs

No response

Validations

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: ssrp3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions