withastro/astro

[Svelte + Cloudflare] Cannot build if the page is prerendered and contains Svelte @render with Cloudflare

GoodLucky777 opened this issue · 1 comments

Astro Info

Astro                    v4.16.16
Node                     v18.20.3
System                   Linux (x64)
Package Manager          unknown
Output                   hybrid
Adapter                  @astrojs/cloudflare
Integrations             @astrojs/svelte

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

No response

Describe the Bug

If I build an Astro website that contains prerendered page with Svelte @render children and Cloudflare integration, the build error occurs. If I remove Cloudflare integration or change prerendered to false, it doesn't.

Build error log:

$ npm run build

19:36:06   └─ /index.htmldocument is not defined
  Hint:
    Browser APIs are not available on the server.
    
    If the code is in a framework component, try to access these objects after rendering using lifecycle methods or use a `client:only` directive to make the component exclusively run on the client.
    
    See https://docs.astro.build/en/guides/troubleshooting/#document-or-window-is-not-defined for more information.
    
  Stack trace:

What's the expected result?

The build should be successful.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/astro-svelte-cloudflare-prerender-build-error

Participation

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