Request lifecycle proble, `Server entry` not run before `Routes`
Environment
$ node -v
v24.11.1
$ grep nitro pnpm-lock.yaml
[email protected]:
[email protected]([email protected]([email protected])):
Reproduction
Describe the bug
on file docs/1.docs/6.server-entry.md desc Request lifecycle
1. Server hook: `request`
2. Route rules (headers, redirects, etc.)
3. Global middleware (middleware/)
4. Server entry ← You are here
5. Routes (routes/)
6. Renderer (renderer.ts or index.html)
Think of the server entry as the last global middleware
test on 3.0.1-alpha.1 ,
create ./middleware/md1.ts file export default () => { console.log("\non mid 1") },
create ./routes/aa.ts file export default ()=>{ console.log(" on routes/aa") /* log but not return */ },
create ./server.ts file export default { fetch(){ console.log(" on server.ts") ; /* log but not return */ } },
curl localhost:3000/other not match routes/*, then run order 3 -> 4 -> 6 ;
curl localhost:3000/aa then run order 3 -> 5 -> END
a. problem 1 NOT RUN 4. Server entry before 5. Routes
b. problem 2 routes.aa run but not return , NOT continue run 6. Renderer get default html
Additional context
$ node -v
v24.11.1
$
$ grep nitro pnpm-lock.yaml
nitro:
[email protected]:
[email protected]([email protected]([email protected])):
$
$ more server/middleware/md1.ts server/routes/aa.ts server/server.ts
::::::::::::::
server/middleware/md1.ts
::::::::::::::
export default () => { console.log("\non mid 1") }
::::::::::::::
server/routes/aa.ts
::::::::::::::
export default ()=>{ console.log(" on routes/aa") /* log but not return */ }
::::::::::::::
server/server.ts
::::::::::::::
export default { fetch(){ console.log(" on server.ts") ; /* log but not return */ } }
$
$ pnpm vite dev
ℹ Using server/server.ts as default route handler. 6:53:32 PM
ℹ Using index.html as renderer template. 6:53:33 PM
ROLLDOWN-VITE v7.2.7 ready in 548 ms
➜ Local: http://localhost:3000/
➜ Network: use --host to expose
➜ press h + enter to show help
on mid 1
on routes/aa
on mid 1
on server.ts
$ curl localhost:3000/aa
$
$ curl localhost:3000/other
<!DOCTYPE html>
...
Logs