nest
nest copied to clipboard
@nestjs/platform-ws: Application shutdown hangs
trafficstars
Is there an existing issue for this?
- [X] I have searched the existing issues
Current behavior
The application shutdown hangs when shutdown hooks are enabled and there are existing (open) websocket connections.
Minimum reproduction code
https://stackblitz.com/edit/nestjs-typescript-starter-1jpeel?file=src%2Fmain.ts&view=editor
Steps to reproduce
- In a first terminal, run
npm install && npm start - In a second terminal, run
node client.mjsto open a WebSocket connection - In the first terminal, stop the application (
Ctrl+C) - In the first terminal, run
npm install && npm startagain -> You get anError: listen EADDRINUSE: address already in use :::3000because the application didn't terminate before.
Expected behavior
The application should have shutdown completely and starting it again should not be an issue.
Package
- [ ] I don't know. Or some 3rd-party package
- [ ]
@nestjs/common - [ ]
@nestjs/core - [ ]
@nestjs/microservices - [ ]
@nestjs/platform-express - [ ]
@nestjs/platform-fastify - [ ]
@nestjs/platform-socket.io - [X]
@nestjs/platform-ws - [ ]
@nestjs/testing - [ ]
@nestjs/websockets - [ ] Other (see below)
Other package
No response
NestJS version
10.3.2
Packages versions
[Nest CLI] Nest CLI Version : 10.3.2
[Nest Platform Information] platform-express version : 10.3.2 platform-ws version : 10.3.2 websockets version : 10.3.2 schematics version : 10.1.1 testing version : 10.3.2 common version : 10.3.2 core version : 10.3.2 cli version : 10.3.2
Node.js version
20.12.2
In which operating systems have you tested?
- [ ] macOS
- [ ] Windows
- [X] Linux
Other
No response