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

Incorrect svelte bundle imported when using svelte 5 with CloudFlare adapter #410

Open
1 task done
giraugh opened this issue Oct 2, 2024 · 1 comment
Open
1 task done

Comments

@giraugh
Copy link

giraugh commented Oct 2, 2024

Astro Info

Astro                    v4.15.10
Node                     v20.10.0
System                   macOS (arm64)
Package Manager          pnpm
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             @astrojs/svelte

Describe the Bug

When running and accessing a built astro app that uses svelte components and the CloudFlare workers adapter, it emits lifecycle_outisde_component errors. Only applies when using svelte 5.

[wrangler:inf] Ready on http://localhost:8788
[wrangler:inf] GET / 200 OK (16ms)
✘ [ERROR] Uncaught (in promise) Error: lifecycle_outside_component

✘ [ERROR] Uncaught (in response) Error: lifecycle_outside_component

From a quick investigation, it seems like the components are importing the client bundle when running in SSR. If I import and log out svelte's onMount() method from the component, it emits the client implementation rather than the noop implementation expected on the server. Could relate to worker import conditions?

Details

  • This issue exists both when using the provided version of vite-plugin-svelte (v3) and overriding the version to v4.
  • Issue does not seem to occur when using svelte 4
  • Issue does not seem to occur when using a different astro adapter (e.g node)

What's the expected result?

Expected page to render as normal without errors.

Link to Minimal Reproducible Example

https://github.com/giraugh/astro-svelte-5-cloudflare-repro

Participation

  • I am willing to submit a pull request for this issue.
@muuvmuuv
Copy link

Rollback to this works for now:

  • @astrojs/cloudflare: 11.0.4
  • astro: 4.16.0

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

No branches or pull requests

3 participants