iis-node / node-server presets can't listen on iisnode named pipe (`NITRO_UNIX_SOCKET` no longer read)
Environment
[email protected][email protected](vianitro/viteplugin),@tanstack/[email protected]- Node 22 on Azure App Service (Windows) behind IIS/iisnode
Reproduction
- Build any app with
preset: "iis-node"(ornode-server), using[email protected]. - Start it with a named pipe in
PORT, as iisnode does:$env:PORT='\\.\pipe\nitro-test'; node index.js - Send a request to the pipe:
require('node:http').request({ socketPath: '\\\\.\\pipe\\nitro-test', path: '/' }, r => console.log(r.statusCode)).end()
Expected: the server listens on the pipe and responds. Actual: the server listens on port 3000, and the request to the pipe fails.
Describe the bug
iisnode passes a named pipe path (e.g. \\.\pipe\3493665b-…) in PORT, not a port number.
The node-server runtime (dist/presets/node/runtime/node-server.mjs) only accepts a numeric port:
var _parsedPort = Number.parseInt(process.env.NITRO_PORT ?? process.env.PORT ?? "");
var port = Number.isNaN(_parsedPort) ? 3e3 : _parsedPort;
serve({ port, hostname: host, /* ... */ })A pipe path parses to NaN, so the server silently falls back to port 3000. iisnode can't reach that port, and every request fails.
The iis-node preset (which extends node-server) still generates an index.js shim that relies on the old NITRO_UNIX_SOCKET behavior (dist/_presets.mjs, writeIISNodeFiles):
if (process.env.PORT.startsWith('\\\\')) {
process.env.NITRO_UNIX_SOCKET = process.env.PORT
delete process.env.PORT
}
import('./server/index.mjs');NITRO_UNIX_SOCKET is no longer read anywhere in the node-server runtime, so the shim has no effect. The iis-node preset therefore cannot work on iisnode as shipped.
In 3.0.1-alpha.0, node-server did support this: server.listen(path ? { path } : { port, host }) with path = process.env.NITRO_UNIX_SOCKET.
Additional context
Workaround
Use the node-middleware preset and create the listener yourself:
// vite.config.ts
nitro({ preset: "node-middleware", serveStatic: true })// run.cjs (iisnode entry, referenced from web.config)
const { createServer } = require("node:http")
const port = (process.env.PORT || "3000").trim()
const target = /^\d+$/.test(port) ? Number(port) : port
import("./server/index.mjs").then(({ middleware }) => {
createServer(middleware).listen(target)
})Suggested fix
Either (or both):
- Support a non-numeric
PORT, orNITRO_UNIX_SOCKET, in thenode-serverruntime. Pass it on as a listen path, if srvx supports that, or fall back tonode:httplisten(path). - Update the
iis-nodepreset shim to match the current runtime behavior.
Logs
Source: nitrojs/nitro