Skip to content

adamchal/cloudflare-prerender-logs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

[Bug]: console.log/console.warn output from workerd is silently swallowed during prerendering

Astro Info

Astro                    v6.1.3
Vite                     v7.3.1
Node                     v25.8.2
System                   macOS (x64)
Package Manager          npm
Output                   static
Adapter                  @astrojs/cloudflare (v13.1.7)
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

N/A (build-time issue)

Describe the Bug

When using @astrojs/cloudflare with hybrid output (mix of prerendered and server-rendered pages), console.log and console.warn calls that execute inside workerd during the prerender phase are silently swallowed. No output appears in the build log.

The prerenderer creates its own Vite preview server with logLevel: "error":

// node_modules/@astrojs/cloudflare/dist/prerenderer.js, line 26-34
previewServer = await preview({
  configFile: false,
  // ...
  logLevel: "error",   // <-- suppresses info/warn output
  // ...
  plugins: [cfVitePlugin({ ...cfPluginConfig, viteEnvironment: { name: "prerender" } })]
});

Worker console.log/console.warn output flows through miniflare's structured logging into ViteMiniflareLogger.info(), which delegates to Vite's logger. Since logLevel: "error", Vite drops anything below error level.

Additionally, because configFile: false is set, user Vite plugins cannot intercept or configure this internal preview server.

What's the expected result?

console.log and console.warn output from workerd during prerendering should appear in the build output, just as they do during astro dev.

This is especially important for debugging prerender-time issues — data fetching errors, missing environment variables, or unexpected data shapes that produce incorrect HTML without any visible error.


Potential fix

The prerender Vite preview server could use logLevel: "info" (or at least "warn") so that worker console output is not suppressed:

previewServer = await preview({
  configFile: false,
  // ...
  logLevel: "info",   // or "warn" as a compromise
  // ...
});

Alternatively, the @cloudflare/vite-plugin could bypass the Vite logger for worker console output and write directly to process.stderr, which would be independent of the Vite log level.

Link to Minimal Reproducible Example

https://github.com/adamchal/cloudflare-prerender-logs

Participation

  • I am willing to submit a pull request for this issue.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors