nest icon indicating copy to clipboard operation
nest copied to clipboard

@nestjs/platform-ws: Application shutdown hangs

Open bettercalljason opened this issue 1 year ago • 0 comments
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

  1. In a first terminal, run npm install && npm start
  2. In a second terminal, run node client.mjs to open a WebSocket connection
  3. In the first terminal, stop the application (Ctrl+C)
  4. In the first terminal, run npm install && npm start again -> You get an Error: listen EADDRINUSE: address already in use :::3000 because 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

bettercalljason avatar May 04 '24 05:05 bettercalljason