Skip to content

Commit d4b9904

Browse files
authored
fix: close idle connections when stopping FastifyController (#857)
1 parent d609f64 commit d4b9904

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/fastify-controller.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@ export class FastifyController {
6464

6565
async #stopServer() {
6666
const { server } = this.#fastify
67-
await promisify(server.close.bind(server))()
67+
68+
const closePromise = promisify(server.close.bind(server))()
69+
70+
// We call this after `server.close()` as recommended by the Node docs (see https://nodejs.org/docs/latest-v20.x/api/http.html#servercloseidleconnections)
71+
server.closeIdleConnections()
72+
73+
await closePromise
6874
}
6975

7076
/**

0 commit comments

Comments
 (0)