Skip to content

fix: resolve node components eagerly in dev to avoid 500 errors on in-flight reloads (#17554) - #17593

Closed
praveen-kumary wants to merge 1 commit into
sveltejs:mainfrom
praveen-kumary:fix/dev-component-eager-resolve
Closed

praveen-kumary wants to merge 1 commit into
sveltejs:mainfrom
praveen-kumary:fix/dev-component-eager-resolve

Conversation

@praveen-kumary

Copy link
Copy Markdown
Contributor

closes #17554

What changed

In packages/kit/src/exports/vite/dev/generate_manifest.js, node.server and node.universal are resolved immediately when building node manifests, while node.component was wrapped in an async getter that deferred resolution until render_response after all load() functions finished.

If a server module is edited while an asynchronous load() is in flight, Vite triggers an SSR program reload. When render_response later evaluated the deferred node.component(), the component was loaded under a fresh svelte/internal/server generation while the request's root.svelte and renderer were initialized under the previous generation, resulting in a 500 error (Cannot read properties of null (reading 'function')).

This patch starts resolving node.component as soon as the node is constructed so the component is imported in the same module generation as root.svelte and the server renderer.

Tests

  • Verified type checking with pnpm check.
  • Verified kit unit tests pass with pnpm test:unit (1,123 passed across 76 suites).

…-flight reloads (sveltejs#17554)

Signed-off-by: praveen-kumary <praveenkumar2000y@gmail.com>
@pkg-svelte-dev

pkg-svelte-dev Bot commented Nov 1, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 72beac9:

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

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

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@changeset-bot

changeset-bot Bot commented Nov 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 72beac9

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

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

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

Comment on lines +101 to +106
const component_promise = resolve(
vite,
vite_dev_server,
runner,
/** @type {string} */ (node.component)
).then(({ module_node, module }) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pages with ssr = false now evaluate their components on the server, causing valid browser-only module code to trigger server errors and Vite error overlays.

Fix on Vercel

@praveen-kumary
praveen-kumary deleted the fix/dev-component-eager-resolve branch November 1, 2026 05:35
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.

Editing a server module while load is running 500s that request: the page component is evaluated against a fresh svelte/internal/server

1 participant