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
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: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.4Used Package Manager
pnpm
Logs
No response
Validations