prerender: wait for env-runner worker readiness before crawling
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- bun, node.js, typescript
- Domain
- backend, build-system
Research direction
Start in src/prerender/prerender.ts, the startup path identified in the issue. Check how the bundled prerender worker is started and whether readiness is awaited before the first route is crawled. Confirm with the supplied slow-entry.mjs and repro.mjs scenario: the first request should wait for readiness, return HTTP 200, and startup failures should still fail the build.
Written by the indexing model from the issue text.
Description
Nitro's bundled prerenderer starts an EnvServer and immediately begins crawling without waiting for worker readiness. A cold import that takes longer than env-runner's approximately 3.1-second address wait causes the first route to fail with HTTP 503, even though the worker starts successfully shortly afterward.
Environment: macOS, Bun 1.4.3, Nitro 3.0.260903-beta, env-runner 0.2.3, TanStack Start.
In our application, requesting /docs through the generated prerender worker returned 503 worker env runner is unavailable after 3,126 ms. The worker became ready after 3,322 ms, and the same request then returned HTTP 200. This makes vite build fail with Exiting due to prerender errors.
Minimal reproduction of the worker startup race, using the env-runner version bundled with this Nitro release:
// slow-entry.mjs
await new Promise((resolve) => setTimeout(resolve, 4_000));
export default { fetch: () => new Response("ready") };
// repro.mjs
import { EnvServer } from "env-runner";
const server = await new EnvServer({
runner: "node-worker",
entry: new URL("./slow-entry.mjs", import.meta.url).pathname,
}).start();
try {
console.log((await server.fetch(new Request("http://localhost/"))).status); // 503
await server.waitForReady();
console.log((await server.fetch(new Request("http://localhost/"))).status); // 200
} finally {
await server.close();
}
Expected behavior: Nitro waits for the prerender worker to become ready before requesting the first route. A startup failure should still fail the build.
The prerender startup path calls .start() without awaiting .waitForReady(). Adding await prerenderer.waitForReady() after .start() fixed the failure locally. Our full build then prerendered 33 routes, and the compiled binary smoke check passed.
This is separate from the Vite SSR import wait fixed in #4295. The affected path here is the bundled prerender worker started during a production build.
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 932
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 164
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nitrojs/nitro
-
v2: backport #4683 (a package's own entry is externalized as `pkg/`, DEP0155)Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 71/100
Maintainers usually reply within 1 day
-
bug externals nuxt v2 windows
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
nitrojs/nitro#4761 · 1 comment ·
Maintainers usually reply within 1 day
-
documentation v3
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
bug v2
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
nitrojs/nitro#4555 · 5 comments ·
Maintainers usually reply within 1 day
-
enhancement preset:vercel v3
Difficulty 4/5 3-5 days Newbie friendliness 48/100
nitrojs/nitro#4876 · 1 reaction ·
Maintainers usually reply within 1 day
Similar issues
-
createAI: the ai peer range allows ai@6, which the provider cannot work withPossibly taken @akhil9tiet claimed this today. Openbug
Difficulty 1/5 Under an hour Newbie friendliness 83/100
cloudflare/agents#2690 · 3 comments ·
Maintainers usually reply within 1 day
-
[fullsend] E2E: theme — global-header ignores app.branding.fullLogo (RHDHBUGS-3670)Possibly taken @fullsend-ai-coder claimed this today. Opene2e-failure ready-to-code
Difficulty 1/5 Under an hour Newbie friendliness 78/100
redhat-developer/rhdh-plugin-export-overlays#4503 · 1 comment ·
Maintainers usually reply within 1 day
-
needs triage 📥
Difficulty 1/5 Under an hour Newbie friendliness 86/100
ethereum/ethereum-org-website#19601 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
cloudscape-design/components#5184 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
agilepathway/label-checker#805 ·
Maintainers usually reply within 1 day