Skip to content

feat: static adapter errors during development#16506

Draft
teemingc wants to merge 6 commits into
feat-server-entrypointfrom
prerender-dev
Draft

feat: static adapter errors during development#16506
teemingc wants to merge 6 commits into
feat-server-entrypointfrom
prerender-dev

Conversation

@teemingc

@teemingc teemingc commented Jul 24, 2026

Copy link
Copy Markdown
Member

poc for throwing prerendering errors during development to help surfaces issues earlier using the custom server entrypoint API. You can go to the static adapter prerender test app, run pnpm dev and try disabling prerendering on any page to see the error surface.

While trying to get this to work, it made me think we need a public API to declare that all pages need to have the prerender option set, etc..

Also, we should consolidate our prerendering checks better. We currently have:

  1. prerendering in $app/env/internal set manually during the forked prerender process
  2. state.prerendering passed in when calling server.respond
  3. state.prerender_default equal to the current page's prerender page option value (we should consolidate to this)

todo: split out some dev prerender error changes not dependent on custom dev server entrypoints


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Jul 24, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from f0d04ad:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/f0d04add53cfdcd79482940f2d0c0469a4fc9f2d

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/16506

@changeset-bot

changeset-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f0d04ad

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@svelte-docs-bot

Copy link
Copy Markdown

Comment on lines +25 to +30
// simulate prerendering during development to surface errors earlier
prerendering: {
dependencies: new Map(),
remote_responses: new Map(),
fallback: __SVELTEKIT_ADAPTER_STATIC_FALLBACK__
},

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There should be a public and easier way to do this

Comment on lines +36 to +54
before_handle: async (event, _config, prerender, handle) => {
if (!event.isSubRequest && !event.isDataRequest && !event.isRemoteRequest && !prerender) {
const error = new Error('Encountered dynamic routes');
error.stack = '';

console.error(
styleText(
['bold', 'red'],
`@sveltejs/adapter-static: all routes must be fully prerenderable, but the ${event.url.pathname} route is dynamic\n`
)
);

console.log(get_options_message(!!Object.keys(event.params).length, false));

throw error;
}
return await handle();
}
});

@teemingc teemingc Jul 24, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Need something public that lets us log errors when a page option isn't set

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

Successfully merging this pull request may close these issues.

1 participant