Skip to content

fix: server islands broken in dev mode with adapters that don't set buildOutput#15703

Merged
matthewp merged 6 commits intomainfrom
fix/server-island-static-dev-15701
Mar 2, 2026
Merged

fix: server islands broken in dev mode with adapters that don't set buildOutput#15703
matthewp merged 6 commits intomainfrom
fix/server-island-static-dev-15701

Conversation

@matthewp
Copy link
Copy Markdown
Contributor

@matthewp matthewp commented Feb 28, 2026

Changes

Testing

  • Added a new test in server-islands.test.js that checks if the server island endpoint can be called.

Docs

N/A, bug fix.

…5701)

Server islands in dev mode with adapters that don't set
adapterFeatures.buildOutput (like @astrojs/netlify) were broken because
buildOutput was reset to 'static' after runHookConfigDone already set it
to 'server' via setAdapter(). This moves the default assignment before
runHookConfigDone, matching the build path ordering.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 28, 2026

🦋 Changeset detected

Latest commit: 2aad653

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 Feb 28, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Feb 28, 2026

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing fix/server-island-static-dev-15701 (2aad653) with main (862d77b)

Open in CodSpeed

@matthewp matthewp marked this pull request as ready for review February 28, 2026 16:20

Fixes server islands returning a 500 error in dev mode for adapters that do not set `adapterFeatures.buildOutput` (e.g. `@astrojs/netlify`)

The `/_server-islands/[name]` endpoint was incorrectly requiring `getStaticPaths()` because `settings.buildOutput` was being reset to `'static'` after the adapter had already set it to `'server'`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem relevant to our users

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, removed.

Comment on lines +397 to +433
describe('dev with adapter that does not set buildOutput', () => {
let devServer;
/** @type {import('./test-utils').Fixture} */
let devFixture;

before(async () => {
// Use an adapter that does NOT set adapterFeatures.buildOutput,
// like @astrojs/netlify. This triggers the bug in container.ts where
// buildOutput is reset to 'static' after runHookConfigDone sets it to 'server'.
devFixture = await loadFixture({
root: './fixtures/server-islands/hybrid',
adapter: testAdapter({
extendAdapter: {
adapterFeatures: {
// Explicitly omit buildOutput to mimic Netlify adapter
},
},
}),
});
devServer = await devFixture.startDevServer();
});

after(async () => {
await devServer?.stop();
});

it('can fetch the server island endpoint in dev mode', async () => {
const res = await devFixture.fetch('/');
assert.equal(res.status, 200);
const html = await res.text();
// Extract the server island fetch URL from the rendered page
const fetchMatch = html.match(/fetch\('(\/_server-islands\/Island[^']*)/);
assert.ok(fetchMatch, 'should have a server island fetch URL');
const islandRes = await devFixture.fetch(fetchMatch[1]);
assert.equal(islandRes.status, 200, 'server island endpoint should return 200, not GetStaticPathsRequired error');
});
});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test can be simplified:

  • it doesn't need a describe
  • it doesn't need before/after hooks

Everything can be done in a simple it because configuration and fixtures are scoped to a single test

Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
@matthewp matthewp merged commit 829182b into main Mar 2, 2026
27 checks passed
@matthewp matthewp deleted the fix/server-island-static-dev-15701 branch March 2, 2026 15:10
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 island on v6 beta causes error (Netlify adapter)

3 participants