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

Closed
1 task done
giraugh opened this issue Oct 2, 2024 · 3 comments · Fixed by #465
Closed
1 task done

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

giraugh opened this issue Oct 2, 2024 · 3 comments · Fixed by #465

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

ahmadyasser72 added a commit to ahmadyasser72/tender-telescope that referenced this issue Dec 2, 2024
adapter cloudflare terdapat flashing content harus pakai client:only untuk komponen inputan dari shadcn-svelte
ref: withastro/adapters#410
@bluwy bluwy closed this as completed in #465 Dec 5, 2024
@yuto343
Copy link

yuto343 commented Dec 18, 2024

This seems to have reappeared in [email protected] and @astrojs/[email protected] 🥲 I downgraded to 12.0.1 to work around it.

@bluwy
Copy link
Member

bluwy commented Dec 18, 2024

Yeah looks like the bug isn't properly fixed, I made a mistake that required a proper fix which indirectly surface this again. There's a new issue opened to be followed instead: #485

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

Successfully merging a pull request may close this issue.

5 participants