Skip to content

server.close in HTTP2 does not close active sessions, they need to be closed manually #5716

@gugu

Description

@gugu

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

4.28.1, but 5 is the same

Plugin version

No response

Node.js version

20.15.1

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

debian-slim

Description

We had slight downtime when we are trying to restart our prod server. After checking source code and documentation I found a mismatch. Fastify calls server.close() only, but it is not enough according to Node.js docs:

server.close([callback])#
...

Stops the server from establishing new sessions. This does not prevent new request streams from being created due to the persistent nature of HTTP/2 sessions. To gracefully shut down the server, call http2session.close() on all active session

Link to code that reproduces the bug

Stackblitz does not work well with http2 streams, so it runs only locally:
https://stackblitz.com/edit/stackblitz-starters-gmr7aj?file=index.js

Expected Behavior

Fastify needs to list all active sessions and close them as well

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions