You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Nest application shutdown, close() is called on the socket.io server here.
Internally socket.io will now disconnect all sockets handled by itself, then calls close() on the underlying http serverhere.
This is a problem because now we are blocking until all connections on the underlying http server are closed, but before the nest application has any chance to run logic that would disconnect other long-running connections. That means that if there's a long running connection that wasn't handled by that socket.io adapter, we now block forever.
For instance this disconnect logic is never reached.
The text was updated successfully, but these errors were encountered:
// FIXME: workaround for https://github.com/nestjs/nest/issues/13910if(forceCloseConnections){constserver=(appasNestExpressApplication).getHttpServer();server.close=(close=>(cb)=>{close(cb);server.closeAllConnections();returnserver;})(server.close.bind(server));}
I think a fix for this is to never call SocketIOServer.close(), and instead track connections ourselves in the websocket adapter, destroy them on close, and also destroy any new incoming connections that may happen after the adapter is stopped, but before nest closes the actual http server.
Another way would be to close the http server early in the shutdown process without waiting for the callback, progress through other shutdown logic, then finally wait for the callback:
Call httpServer.close(closeCallback), this will synchronously make it not accept new connections
Perform nest application shutdown
if forceCloseConnections is set, call destroy() on all remaining sockets
wait for closeCallback
With the latter way it is up to each component what it wants to do with in-flight requests during shutdown, but they won't have to worry about new requests coming in.
On Nest application shutdown,
close()
is called on the socket.io server here.Internally socket.io will now disconnect all sockets handled by itself, then calls close() on the underlying http server here.
This is a problem because now we are blocking until all connections on the underlying http server are closed, but before the nest application has any chance to run logic that would disconnect other long-running connections. That means that if there's a long running connection that wasn't handled by that socket.io adapter, we now block forever.
For instance this disconnect logic is never reached.
The text was updated successfully, but these errors were encountered: