Skip to content

Commit

Permalink
fix: close idle connections when stopping FastifyController (#857)
Browse files Browse the repository at this point in the history
  • Loading branch information
achou11 authored Sep 23, 2024
1 parent d609f64 commit d4b9904
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/fastify-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ export class FastifyController {

async #stopServer() {
const { server } = this.#fastify
await promisify(server.close.bind(server))()

const closePromise = promisify(server.close.bind(server))()

// We call this after `server.close()` as recommended by the Node docs (see https://nodejs.org/docs/latest-v20.x/api/http.html#servercloseidleconnections)
server.closeIdleConnections()

await closePromise
}

/**
Expand Down

0 comments on commit d4b9904

Please sign in to comment.