Skip to content

Conversation

@wadefletch
Copy link
Contributor

@wadefletch wadefletch commented Feb 9, 2026

Linked issue

Type of change

  • Documentation (updates to the documentation, readme, or JSdoc annotations)
  • Bug fix (a non-breaking change that fixes an issue)
  • Enhancement (improving an existing functionality like performance)
  • New feature (a non-breaking change that adds functionality)
  • Chore (updates to the build process or auxiliary tools and libraries)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

Implement env vars across runtimes

Wires documented-but-unimplemented env vars through to srvx serve() options in the Node, Bun, and Deno server presets:

  • NITRO_UNIX_SOCKET: Passes socket path to srvx via node: { path } (Node.js) and bun: { unix } (Bun). Not available for Deno as Deno.serve does not support UNIX sockets. Resolves UNIX socket support for bun preset. #1740.
  • NITRO_SHUTDOWN_DISABLED: Maps to gracefulShutdown: false when set to 'true'.
  • NITRO_SHUTDOWN_TIMEOUT: Maps to gracefulShutdown: { gracefulTimeout } (converted from ms to seconds for srvx).

Wiring gracefulShutdown through to srvx for the Bun preset should also resolve #2566 (close hook not executing with Bun preset), since srvx's graceful shutdown plugin handles SIGINT/SIGTERM and triggers proper server close.

Remove env vars that cannot be configured through srvx

Two env vars were previously documented but cannot be implemented through srvx's current API, so they are removed from the docs rather than left as misleading:

Add env var docs for Bun and Deno runtimes

The Bun and Deno runtime pages previously had no env var documentation. Now they document the variables supported by each runtime.

Fix Node.js handler preset docs

The "Handler (advanced)" section referenced preset node and export listener, but node is an alias for node-server (the full server). The actual preset is node_middleware and the export is middleware.

Alignment with srvx

Verified against srvx v0.11.2 (which nitro is pinned to via ^0.11.2). The graceful shutdown plugin was refactored in h3js/srvx@54e7074:

  • gracefulTimeout is the only config option the implementation reads (forceTimeout is still in the type but no longer used)
  • Default timeout is 5s (up from 3s) -- docs updated accordingly
  • Signals remain hardcoded to SIGINT/SIGTERM
  • process.exit(0) is always called after close

Our passthrough of { gracefulTimeout } aligns with both the current implementation and the type interface.

Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@wadefletch wadefletch requested a review from pi0 as a code owner February 9, 2026 22:49
@vercel
Copy link

vercel bot commented Feb 9, 2026

@wadefletch is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Feb 9, 2026

📝 Walkthrough

Walkthrough

Documents environment variables for Node, Bun, and Deno; renames Node handler preset to node_middleware; and wires Unix socket support and graceful-shutdown configuration into Bun and Node runtimes and graceful-shutdown into Deno runtime.

Changes

Cohort / File(s) Summary
Documentation
docs/2.deploy/10.runtimes/1.node.md, docs/2.deploy/10.runtimes/bun.md, docs/2.deploy/10.runtimes/deno.md
Added/updated "Environment Variables" sections. Node: annotated NITRO_UNIX_SOCKET as "(Node.js and Bun only)", reorganized shutdown entries and adjusted defaults/descriptions (including NITRO_SHUTDOWN_TIMEOUT change), and renamed handler preset to node_middleware with middleware examples. Bun/Deno: added Nitro env var docs and shutdown defaults.
Bun runtime
src/presets/bun/runtime/bun.ts
Exposed NITRO_UNIX_SOCKET as socketPath/bun.unix; parsed NITRO_SHUTDOWN_TIMEOUT and NITRO_SHUTDOWN_DISABLED to compute a gracefulShutdown value and passed it to serve(...).
Deno runtime
src/presets/deno/runtime/deno-server.ts
Parsed NITRO_SHUTDOWN_TIMEOUT and NITRO_SHUTDOWN_DISABLED, derived gracefulShutdown (false
Node runtime
src/presets/node/runtime/node-server.ts
Enabled socketPath from NITRO_UNIX_SOCKET (Node IPC), parsed _shutdownTimeout and NITRO_SHUTDOWN_DISABLED to compute gracefulShutdown, and passed it into the server configuration.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description is detailed and directly related to the changeset, explaining the implementation of environment variables and documentation fixes.
Linked Issues check ✅ Passed The code changes implement all primary objectives: NITRO_UNIX_SOCKET support for Bun (#1740), graceful shutdown handling via srvx for Bun (#2566), environment variable documentation for Bun and Deno, and Node.js handler docs fixes.
Out of Scope Changes check ✅ Passed All changes are within scope: environment variable implementation in three runtimes, documentation updates for runtime pages and handler docs, with no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title follows conventional commits format with a type prefix (feat), scope (node,deno,bun), and descriptive subject that accurately reflects the main changes in the PR.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@wadefletch wadefletch changed the title feat: implement NITRO_UNIX_SOCKET and graceful shutdown env vars feat(node,deno,bun): implement NITRO_UNIX_SOCKET and graceful shutdown env vars Feb 9, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@docs/2.deploy/10.runtimes/bun.md`:
- Line 21: The document has a heading-level skip (h1 to h3) at the "Environment
Variables" section similar to deno.md which triggers markdownlint MD001; update
the heading hierarchy so levels are consecutive (e.g., change the "Environment
Variables" heading to h2 or adjust surrounding headings) to eliminate the h1→h3
jump and keep consistency with the project style and deno.md; ensure the change
only alters the markdown heading markers (e.g., from ### to ##) in the
docs/2.deploy/10.runtimes/bun.md file.

In `@docs/2.deploy/10.runtimes/deno.md`:
- Line 21: The "Environment Variables" heading currently uses an h3 (###) which
jumps from h1 to h3; change it to h2 (##) so heading levels don't skip, or
alternatively change surrounding headings in this doc to match the project's
existing convention (as seen in "1.node.md") so all runtime docs use consistent
heading levels; update the "Environment Variables" heading text accordingly and
verify the rest of this markdown follows the same h-level pattern.


:read-more{to="https://bun.sh"}

### Environment Variables
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Same h1h3 heading level skip as in deno.md.

Same markdownlint MD001 concern. Consistent with the project pattern but worth addressing if the project decides to fix heading levels.

🤖 Prompt for AI Agents
In `@docs/2.deploy/10.runtimes/bun.md` at line 21, The document has a
heading-level skip (h1 to h3) at the "Environment Variables" section similar to
deno.md which triggers markdownlint MD001; update the heading hierarchy so
levels are consecutive (e.g., change the "Environment Variables" heading to h2
or adjust surrounding headings) to eliminate the h1→h3 jump and keep consistency
with the project style and deno.md; ensure the change only alters the markdown
heading markers (e.g., from ### to ##) in the docs/2.deploy/10.runtimes/bun.md
file.

deno run --unstable --allow-net --allow-read --allow-env .output/server/index.ts
```

### Environment Variables
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Heading level skips from h1 to h3.

Static analysis (markdownlint MD001) flags this as jumping from # to ###. However, this is consistent with the existing pattern in 1.node.md (Line 28), so this may be intentional for the project. Consider aligning with the project's heading conventions.

🧰 Tools
🪛 markdownlint-cli2 (0.20.0)

[warning] 21-21: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)

🤖 Prompt for AI Agents
In `@docs/2.deploy/10.runtimes/deno.md` at line 21, The "Environment Variables"
heading currently uses an h3 (###) which jumps from h1 to h3; change it to h2
(##) so heading levels don't skip, or alternatively change surrounding headings
in this doc to match the project's existing convention (as seen in "1.node.md")
so all runtime docs use consistent heading levels; update the "Environment
Variables" heading text accordingly and verify the rest of this markdown follows
the same h-level pattern.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 9, 2026

Open in StackBlitz

npm i https://pkg.pr.new/nitrojs/nitro@4013

commit: 3482064

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@docs/2.deploy/10.runtimes/1.node.md`:
- Line 57: Replace the unhyphenated phrase "Node.js compatible handler" with
"Node.js-compatible handler" in the sentence that reads "Nitro also has a more
low-level preset that directly exports a Node.js compatible handler usable for
middleware and custom servers." to apply the correct hyphenation for the
compound modifier; update the string exactly where that text appears in the
docs.

**Preset:** `node_middleware`

Nitro also has a more low-level preset that directly exports a function with `(req, res) => {}` signature usable for middleware and custom servers.
Nitro also has a more low-level preset that directly exports a Node.js compatible handler usable for middleware and custom servers.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Hyphenate “Node.js‑compatible”.

Grammar nit: “Node.js compatible” should be “Node.js‑compatible”.

🧰 Tools
🪛 LanguageTool

[grammar] ~57-~57: Use a hyphen to join words.
Context: ...l preset that directly exports a Node.js compatible handler usable for middleware...

(QB_NEW_EN_HYPHEN)

🤖 Prompt for AI Agents
In `@docs/2.deploy/10.runtimes/1.node.md` at line 57, Replace the unhyphenated
phrase "Node.js compatible handler" with "Node.js-compatible handler" in the
sentence that reads "Nitro also has a more low-level preset that directly
exports a Node.js compatible handler usable for middleware and custom servers."
to apply the correct hyphenation for the compound modifier; update the string
exactly where that text appears in the docs.

@wadefletch wadefletch changed the title feat(node,deno,bun): implement NITRO_UNIX_SOCKET and graceful shutdown env vars feat(node,deno,bun): implement env vars and fix handler docs Feb 10, 2026
wadefletch and others added 3 commits February 9, 2026 18:47
Wire NITRO_UNIX_SOCKET, NITRO_SHUTDOWN_DISABLED, and
NITRO_SHUTDOWN_TIMEOUT through to srvx serve options in the Node, Bun,
and Deno server presets.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
The Handler (advanced) section referenced preset `node` and export `listener`,
but `node` is an alias for `node-server` (not the middleware handler). The
actual preset name is `node-middleware` and the export is `middleware`.

Co-authored-by: Cursor <cursoragent@cursor.com>
@wadefletch wadefletch force-pushed the wade/implement-env-vars branch from a47c3ae to 3482064 Compare February 10, 2026 00:48
@wadefletch wadefletch changed the title feat(node,deno,bun): implement env vars and fix handler docs feat(node,deno,bun): implement env vars, remove impractical ones, fix handler docs Feb 10, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@docs/2.deploy/10.runtimes/bun.md`:
- Around line 29-30: Update the docs entry for the environment variable
NITRO_SHUTDOWN_TIMEOUT in the Bun runtime docs to use the correct default of
5000 milliseconds (to match Node.js docs and srvx's gracefulTimeout), i.e.,
change the documented default from `3000` to `5000` and ensure the description
remains consistent with the existing NITRO_SHUTDOWN_DISABLED line and the
Node.js `NITRO_SHUTDOWN_TIMEOUT` documentation.

In `@docs/2.deploy/10.runtimes/deno.md`:
- Around line 28-29: Update the NITRO_SHUTDOWN_TIMEOUT default in
docs/2.deploy/10.runtimes/deno.md from 3000 to 5000 to match the Node.js docs
and srvx's default gracefulTimeout (5 seconds); specifically change the
`NITRO_SHUTDOWN_TIMEOUT` line so it states the default is `5000` milliseconds
(and verify the `NITRO_SHUTDOWN_DISABLED` line remains unchanged) to keep
defaults consistent with bun.md and Node.js documentation.

Comment on lines +29 to +30
- `NITRO_SHUTDOWN_DISABLED` - Disables the graceful shutdown feature when set to `'true'`. Defaults to `'false'`.
- `NITRO_SHUTDOWN_TIMEOUT` - Sets the amount of time (in milliseconds) before a forced shutdown occurs. Defaults to `3000` milliseconds.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Inconsistent default for NITRO_SHUTDOWN_TIMEOUT across runtime docs.

This says the default is 3000 milliseconds, but the Node.js docs (line 37 of 1.node.md) document it as 5000 milliseconds. Per the PR objectives and srvx's default gracefulTimeout of 5 seconds, the correct value should be 5000.

Proposed fix
-- `NITRO_SHUTDOWN_TIMEOUT` - Sets the amount of time (in milliseconds) before a forced shutdown occurs. Defaults to `3000` milliseconds.
+- `NITRO_SHUTDOWN_TIMEOUT` - Sets the amount of time (in milliseconds) before a forced shutdown occurs. Defaults to `5000` milliseconds.
🤖 Prompt for AI Agents
In `@docs/2.deploy/10.runtimes/bun.md` around lines 29 - 30, Update the docs entry
for the environment variable NITRO_SHUTDOWN_TIMEOUT in the Bun runtime docs to
use the correct default of 5000 milliseconds (to match Node.js docs and srvx's
gracefulTimeout), i.e., change the documented default from `3000` to `5000` and
ensure the description remains consistent with the existing
NITRO_SHUTDOWN_DISABLED line and the Node.js `NITRO_SHUTDOWN_TIMEOUT`
documentation.

Comment on lines +28 to +29
- `NITRO_SHUTDOWN_DISABLED` - Disables the graceful shutdown feature when set to `'true'`. Defaults to `'false'`.
- `NITRO_SHUTDOWN_TIMEOUT` - Sets the amount of time (in milliseconds) before a forced shutdown occurs. Defaults to `3000` milliseconds.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Same inconsistent NITRO_SHUTDOWN_TIMEOUT default as in bun.md.

Should be 5000 milliseconds to match the Node.js docs and srvx's default gracefulTimeout of 5 seconds.

Proposed fix
-- `NITRO_SHUTDOWN_TIMEOUT` - Sets the amount of time (in milliseconds) before a forced shutdown occurs. Defaults to `3000` milliseconds.
+- `NITRO_SHUTDOWN_TIMEOUT` - Sets the amount of time (in milliseconds) before a forced shutdown occurs. Defaults to `5000` milliseconds.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- `NITRO_SHUTDOWN_DISABLED` - Disables the graceful shutdown feature when set to `'true'`. Defaults to `'false'`.
- `NITRO_SHUTDOWN_TIMEOUT` - Sets the amount of time (in milliseconds) before a forced shutdown occurs. Defaults to `3000` milliseconds.
- `NITRO_SHUTDOWN_DISABLED` - Disables the graceful shutdown feature when set to `'true'`. Defaults to `'false'`.
- `NITRO_SHUTDOWN_TIMEOUT` - Sets the amount of time (in milliseconds) before a forced shutdown occurs. Defaults to `5000` milliseconds.
🤖 Prompt for AI Agents
In `@docs/2.deploy/10.runtimes/deno.md` around lines 28 - 29, Update the
NITRO_SHUTDOWN_TIMEOUT default in docs/2.deploy/10.runtimes/deno.md from 3000 to
5000 to match the Node.js docs and srvx's default gracefulTimeout (5 seconds);
specifically change the `NITRO_SHUTDOWN_TIMEOUT` line so it states the default
is `5000` milliseconds (and verify the `NITRO_SHUTDOWN_DISABLED` line remains
unchanged) to keep defaults consistent with bun.md and Node.js documentation.

@wadefletch wadefletch changed the title feat(node,deno,bun): implement env vars, remove impractical ones, fix handler docs feat(node,deno,bun): implement env vars, remove srvx-deprecated ones, fix handler docs Feb 10, 2026
@wadefletch
Copy link
Contributor Author

Superseded by #4017 which combines this with #4016 into a single comprehensive graceful shutdown PR.

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

Labels

None yet

Projects

None yet

1 participant