Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cloudflare + Svelte 5] Cannot build with Cloudflare if the page is prerendered and contains passing children to Svelte 5 component #456

Open
1 task
GoodLucky777 opened this issue Dec 1, 2024 · 2 comments

Comments

@GoodLucky777
Copy link

GoodLucky777 commented Dec 1, 2024

Astro Info

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

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:

Also, <slot /> is not working too.

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.
@GoodLucky777 GoodLucky777 changed the title [Cloudflare + Svelte 5] Cannot build if the page is prerendered and contains Svelte 5 @render with Cloudflare [Cloudflare + Svelte 5] Cannot build with Cloudflare if the page is prerendered and contains passing children to Svelte 5 component Dec 1, 2024
@rdlogout
Copy link

+1
facing same issue when using @astrojs/cloudflare adapter
getting
✘ [ERROR] Uncaught (in response) Error: lifecycle_outside_component when trying to use svelte context in ssr
and document is not define when try to render children

@alexanderniebuhr
Copy link
Member

This might be also duplicate of #485

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants