Skip to content

Since fastify 4, fastify no longer waits for existing requests to finish when calling fastify.close() #4098

@corevo

Description

@corevo

Prerequisites

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

Last working version

3.29.0

Stopped working in version

4.0.0

Node.js version

18.4.0

Operating system

macOS

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

12.4

💥 Regression Report

As of fastify 4, fastify does not wait for requests made before instance.close was called to finish, rather it shuts down immediately and hangs up the connection.

Steps to Reproduce

A repo that repros the issue is available here

Steps to reproduce the issue:

$ git clone [email protected]:corevo/fastify-shutdown-regression.git
$ cd fastify-3
$ npm i
$ npm t
# should exit with 'OK' and exit code 0
$ cd fastify-4
$ npm i
$ npm t
# will instead fail on socket hang up

Expected Behavior

When calling instance.close fastify should wait up to a certain (ideally configurable) grace period, for any request that has already been made prior to closing to finish.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions