Repository navigation
Description
Astro Info
astro 7.3.2
@astrojs/cloudflare 14.3.1
wrangler 4.131.2
workerd 1.20260915.1
miniflare 5.20260915.0-alpha
Node v22.23.1
Package manager npm
OS macOS
Describe the Bug
With nodejs_compat enabled and a compatibility_date of 2025-10-01 or later, every prerendered route builds to a 15-byte file containing the literal string [object Object] instead of HTML.
The build reports success — no error, no warning. SSR routes are unaffected; only prerender = true routes are corrupted.
This is easy to miss precisely because the build is green. The broken output only surfaces once it's served — it reached our production site this way, on every static page at once.
What's the expected result?
dist/client/index.html contains the rendered HTML.
Instead it contains exactly [object Object] (15 bytes).
Link to Minimal Reproducible Example
Four files, no integrations, no app code:
package.json
{
"name": "cf-prerender-repro",
"type": "module",
"private": true,
"scripts": { "build": "astro build" },
"dependencies": {
"@astrojs/cloudflare": "14.3.1",
"astro": "7.3.2",
"wrangler": "4.131.2"
}
}astro.config.mjs
import { defineConfig } from 'astro/config';
import cloudflare from '@astrojs/cloudflare';
export default defineConfig({
output: 'server',
adapter: cloudflare(),
});wrangler.toml
name = "cf-prerender-repro"
compatibility_date = "2025-12-01"
compatibility_flags = ["nodejs_compat"]src/pages/index.astro
---
export const prerender = true;
---
<html><body><h1>hello</h1></body></html>npm install && npm run build && cat dist/client/index.html
Expected: <!DOCTYPE html><html><body><h1>hello</h1></body></html>
Actual: [object Object]
Isolation
Each row is that same reproduction with only wrangler.toml changed:
compatibility_date |
compatibility_flags |
dist/client/index.html |
|---|---|---|
| 2025-12-01 | [] |
117 bytes, correct HTML |
| 2025-12-01 | ["global_fetch_strictly_public"] |
117 bytes, correct HTML |
| 2025-12-01 | ["nodejs_compat"] |
15 bytes, [object Object] |
| 2025-09-30 | ["nodejs_compat"] |
117 bytes, correct HTML |
| 2025-10-01 | ["nodejs_compat"] |
15 bytes, [object Object] |
| 2025-12-01 | ["nodejs_compat", "disable_nodejs_process_v2"] |
117 bytes, correct HTML |
The trigger is enable_nodejs_process_v2, which becomes default-on for nodejs_compat at compatibility_date >= 2025-10-01. The date boundary is exactly 2025-09-30 (fine) → 2025-10-01 (broken), and adding disable_nodejs_process_v2 is a complete workaround.
Where it goes wrong
Instrumenting astro/dist/core/build/generate.js where the prerendered body is read shows the corruption already present in the response coming back from the prerender worker:
/ status=200 content-type=text/html len=15 head="[object Object]"
So the body is bad before Astro writes the file — it originates inside the prerender worker, not in the build's file handling.
It looks like the streaming render path. Patching the adapter's own handler:
// node_modules/@astrojs/cloudflare/dist/utils/handler.js
- const app = createApp();
+ const app = createApp({ streaming: false });…makes every prerendered page render correctly (our homepage went from 15 bytes to 77,209 bytes of valid HTML). That's a local patch rather than a fix, but it narrows the interaction to streaming + process v2.
Possibly related: our app already carried this comment from an earlier version pairing, so a streaming variant of this may predate the current releases —
// Astro 6.1.9 + @astrojs/cloudflare 13.2.1 can stream plain render instructions
// as "[object Object]" for this app's SSR pages. Non-streaming renders full HTML.
const app = createApp({ streaming: false });Since nodejs_compat plus a current compatibility_date is a common Workers setup, this likely affects a fair number of projects, and the silent-success failure mode means they may not find out until it's deployed.
Participation
- I am willing to submit a pull request for this issue.
Activity
astro-factory commentedon Sep 15, 2026
Triage complete
triage: fix pendingdist/client/index.htmlcontains[object Object](15 bytes) instead of HTML whennodejs_compatis enabledpackages/integrations/cloudflare/test/prerender-nodejs-compat.test.tsnodejs_compat), and the build reports success with no warnings. Thedisable_nodejs_process_v2workaround exists but is non-obvious.When workerd runs with
nodejs_compat, theprocessglobal satisfies Astro'sisNodecheck inpackages/astro/src/runtime/server/render/util.ts, causingrenderPageto userenderToAsyncIterableand pass the resultingAsyncIterableto workerd'sResponseconstructor. Workerd does not supportAsyncIterableas a body (it's a non-standard Node.js extension), so it stringifies the object to[object Object]. This exact issue was previously fixed in PR #16720, but that fix was reverted in PR #16997 because therenderToReadableStreamfallback caused a build-time performance regression for large sites.I found a potential fix for this issue. The fix adds
isWorkerddetection (vianavigator.userAgent === 'Cloudflare-Workers') and, when in workerd, wraps theAsyncIterablewithReadableStream.from()instead of passing it directly to theResponseconstructor. This preserves the fasterrenderToAsyncIterablerendering path (avoiding the performance regression that caused the previous revert) while producing a standardBodyInittype that workerd accepts.Try this fix
You can test this fix right now without waiting for a release:
If this fixes your issue, please leave a comment letting us know (for example
"confirmed, this fixes it"). A pull request will then be opened to get it merged.
Full Triage Report
Reproduction
Confirmed with a minimal reproduction:
astro.config.mjswithoutput: 'server'+adapter: cloudflare(),wrangler.tomlwithnodejs_compat, and a single prerendered page. Build succeeds but output is[object Object].dist/client/index.htmlcompatibility_flags = ["nodejs_compat"][object Object](15 bytes) — BROKENcompatibility_flags = []compatibility_flags = ["nodejs_compat", "disable_nodejs_process_v2"]Root Cause
In
packages/astro/src/runtime/server/render/util.ts:With
nodejs_compat, workerd'sprocessglobal passes this check. Inpackages/astro/src/runtime/server/render/page.ts, the streaming path then usesrenderToAsyncIterableand passes theAsyncIterable<Uint8Array>tonew Response(body, ...). Workerd'sResponseconstructor doesn't supportAsyncIterable(a non-standard Node.js extension) and falls back to.toString(), producing[object Object].Instrumentation confirmed:
isNode: true, isDeno: false, streaming: trueinside workerd withnodejs_compat.History
isNode→ fixed[object Object]renderToReadableStreamfallback was slower for large sitesFix
Added
isWorkerddetection andReadableStream.from()wrapping in the workerd branch (keeps fastrenderToAsyncIterablerendering, wraps output to standardReadableStreamforResponseconstructor compatibility).Changes
packages/astro/src/runtime/server/render/util.ts— AddedisWorkerdconstantpackages/astro/src/runtime/server/render/page.ts— WrapAsyncIterablewithReadableStream.from()in workerdpackages/integrations/cloudflare/test/prerender-nodejs-compat.test.ts— Integration test.changeset/neat-dingos-sip.md—astro: patchVerification
nodejs_compat: correct HTML outputnodejs_compat: correct HTML output (no regression)This report was made by an LLM. The analysis may be wrong, and the potential fix might not work, but is intended as a starting point for exploring the issue.
matthewp commentedon Sep 16, 2026
Bot, I can confirm this fixes it.
astro-factory commentedon Sep 16, 2026
The fix has been verified! A pull request has been created: #18011
Fix prerendered Cloudflare pages rendering as [object Object] with no…