Skip to content

feat(@astrojs/node): add graceful shutdown to standalone mode - #17655

Open
WhatCats wants to merge 1 commit into
withastro:mainfrom
WhatCats:feat/node-graceful-shutdown
Open

feat(@astrojs/node): add graceful shutdown to standalone mode#17655
WhatCats wants to merge 1 commit into
withastro:mainfrom
WhatCats:feat/node-graceful-shutdown

Conversation

@WhatCats

Copy link
Copy Markdown

Overview

Adds graceful shutdown support to the Node.js standalone adapter. When the process receives SIGTERM or SIGINT, the server stops accepting new connections and waits for all in-flight requests to complete before exiting.

What's new

  • SIGTERM / SIGINT handling — the server closes gracefully on either signal
  • Force-destroy timeout — if connections don't drain within the timeout, remaining connections are force-destroyed. Default is 10s, configurable via ASTRO_NODE_GRACEFUL_SHUTDOWN_TIMEOUT (milliseconds)
  • Opt-out — set ASTRO_NODE_GRACEFUL_SHUTDOWN=disabled to skip signal handler registration entirely

Testing

Adds an integration test suite (graceful-shutdown.test.ts) covering:

  • No new connections accepted after server.close()
  • SIGTERM and SIGINT each independently stop the server (SIGINT tested on a fresh server)
  • Multiple concurrent in-flight requests all complete before closed() resolves
  • Force-destroy fires after timeout when a connection is permanently stalled

Docs

Docs have not been updated yet.

@github-actions github-actions Bot added the pkg: integration Related to any renderer integration (scope) label Aug 10, 2026
@changeset-bot

changeset-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 415bd9f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 34 packages
Name Type
@astrojs/node Minor
@e2e/actions-blog Patch
@e2e/actions-react-19 Patch
@e2e/csp-server-islands Patch
@e2e/i18n Patch
@e2e/server-islands-key Patch
@e2e/server-islands Patch
@e2e/view-transitions Patch
@test/client-address-node Patch
@test/live-loaders Patch
@test/request-signal Patch
@test/static-build-ssr Patch
@test/nodejs-api-route Patch
@test/nodejs-badurls Patch
@test/nodejs-encoded Patch
@test/nodejs-errors Patch
@test/nodejs-graceful-shutdown Patch
@test/nodejs-headers Patch
@test/nodejs-image Patch
@test/locals Patch
@test/node-middleware Patch
@test/nodejs-prerender-404-500 Patch
@test/nodejs-prerender Patch
@test/nodejs-prerendered-error-page-fetch Patch
@test/nodejs-preview-headers Patch
@test/redirects Patch
@test/node-sessions Patch
@test/ssr-assets-middleware Patch
@test/node-static-headers Patch
@test/node-trailingslash Patch
@test/url Patch
@test/well-known-locations Patch
@test/sitemap-ssr Patch
astro-benchmark Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: integration Related to any renderer integration (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant