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

Fix server islands for prerender-only sites #12982

Merged
merged 7 commits into from
Jan 17, 2025
Merged

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Jan 14, 2025

Changes

fix #12803

Summary of issue:

  1. Server islands work using endpoints.
  2. It's added if Astro detects a page is being server-rendered, or if pages are configured to server-render by default (output: "server").
  3. However, if the project happens to not set output (defaults to "static"), and all pages in src/pages are statically built (no export const prerender = false), then because of no2, the server island endpoints will not be added.
  4. As a result, the build output is missing the /_server-islands/ handling and fails in the browser.

This PR:

  • Fixes the issue by adding the server islands endpoint whenever it detects an adapter is being used. Should not be a problem for server-based adapters, but for static-based adapters, I believe it's still ok as they can specify in adapterFeaturs.buildOutput: 'static' and Astro will error that server islands won't work if they're used after building.

Testing

This one is a bit hard to write a test for, but I've updated some existing tests to match this new behaviour, and also manually ran the test in the adapters repo against this PR. It affects one Cloudflare test, but IIUC it's not breaking anything and should only require updating the code/test there to refine the output only. (This specific test)

Docs

n/a. bug fix.

Copy link

changeset-bot bot commented Jan 14, 2025

🦋 Changeset detected

Latest commit: 8961688

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Jan 14, 2025
Copy link

codspeed-hq bot commented Jan 14, 2025

CodSpeed Performance Report

Merging #12982 will not alter performance

Comparing fix-server-island-static (8961688) with main (df90e6d)

Summary

✅ 6 untouched benchmarks

@bluwy bluwy marked this pull request as ready for review January 16, 2025 15:32
@bluwy bluwy merged commit 429aa75 into main Jan 17, 2025
16 checks passed
@bluwy bluwy deleted the fix-server-island-static branch January 17, 2025 15:25
@astrobot-houston astrobot-houston mentioned this pull request Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Server islands respond with 404 when deployed to vercel
2 participants