Skip to content

Nitro close hook is not called on shutdown with the Vite integration and Bun preset #4479

Closed

Description

@slowcode42

Environment

Environment

  • Nitro: 3.0.260610-beta
  • Runtime preset: bun
  • Integration: nitro/vite
  • Runtime: Bun

Description

When using Nitro through the Vite integration with the Bun preset, callbacks registered on the Nitro runtime close hook are not called when the production server shuts down.

The srvx server handles SIGINT and prints Server closed successfully., but the Nitro close hook is never invoked.

Reproduction

Reproduction

Vite configuration:

import { nitro } from 'nitro/vite'

export default {
  plugins: [
    nitro({
      preset: 'bun',
      plugins: ['src/plugin.ts']
    })
  ]
}

Nitro runtime plugin:

import { definePlugin } from 'nitro'

export default definePlugin((app) => {
  app.hooks.hook('close', async () => {
    console.log('Nitro close hook called')
    // Dispose application resources
  })
})

Build and start the server:

vite build
PORT=3330 bun .output/server/index.mjs

Then press Ctrl+C.
Observed output:

Server closed successfully.
error: interrupted by SIGINT

Nitro close hook called is never printed.

Describe the bug

The runtime plugin is correctly included in .output/server/index.mjs and successfully registers the callback.

However, the generated Bun entry passes nitroApp.fetch to serve(), while srvx handles graceful shutdown independently.

The srvx shutdown does not appear to be connected to the Nitro runtime close hook.

Additional context

No response

Logs

Activity

  1. added
    pending triage
    on Jul 24, 2026
  2. added
    bug
    and removed
    pending triage
    on Sep 2, 2026
  3. added theissue type on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions