Skip to content

Commit

Permalink
fix: gracefully close open sockets (#137)
Browse files Browse the repository at this point in the history
When attempting a graceful shutdown, if a page is open with a HMR websocket, it will prevent shutting down. Use the `onClose` hook to shut down the dev server.
  • Loading branch information
matt-smarsh committed Feb 27, 2024
1 parent beb415c commit 1a8c956
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/fastify-vite/mode/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ async function setup(config) {
}
})

// Close the dev server when Fastify closes
this.scope.addHook('onClose', () => this.devServer.close())

// Load routes from client module (server entry point)
const { module: clientModule } = await loadClient()
const client = await config.prepareClient(clientModule, this.scope, config)
Expand Down

0 comments on commit 1a8c956

Please sign in to comment.