Repository navigation
fix: inline seroval and seroval-plugins in dev SSR - #397
Merged
Merged
Conversation
Under `vite dev` the SSR environment already inlines `solid-js` and `@solidjs/web` so their `dist/dev` builds load once end to end. `seroval` and `seroval-plugins` split the same way: both ship a `dist/dev` build behind the `development` condition, and `@solidjs/web` imports both. Left external, `seroval-plugins` loads through Node and its own `import "seroval"` resolves to the prod copy, while the inlined `@solidjs/web` gets the runner's dev copy. Seroval detects streams with `instanceof Stream`, so the `Stream` that `ReadableStreamPlugin` builds from one copy is rejected by the other copy's serializer. Server components hit this when a component resolves after the shell flush: its `sc:live` ReadableStream fails with "Seroval caught an error during the parsing process … cannot be parsed/serialized", `<Loading>` contains the error, and the component only renders on the client. Builds bundle one copy and are unaffected. Adds a config-level test (examples/start-ssr/test/ssr-inline.mjs). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: ae8a8b0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With
serverFunctions: { components: true }in SSR start mode, a server component that resolves after the shell flushes (for example one thatawaits before returning) fails undervite dev:The
<Loading>boundary contains the error, so the component silently renders only on the client. Production builds are fine.Cause
Two copies of
serovalload in dev SSR:@solidjs/webgetsserovalfrom the module runner, which resolves with thedevelopmentcondition, so it loadsdist/dev/index.js.seroval-pluginsis externalized, so Node loads it and resolves its ownimport "seroval"withoutdevelopment, which loadsdist/index.js.Seroval detects streams with
value instanceof Stream.ReadableStreamPluginbuilds itsStreamwith one copy and the serializer checks it against the other, so the check fails. A server component hits this through itssc:livechannel, aReadableStreamserialized into the document. I confirmed the two copies by logging each module evaluation and tracing the rejected value back tosc:live.This is the same split the plugin already handles for
solid-js/@solidjs/web(the comment above the existing inline list describes it).Fix
Add
serovalandseroval-pluginsto the dev SSR inline list next tosolid-jsand@solidjs/web. The existing guards still apply: dev only, Vitest projects and hosts that setnoExternal: trueare left alone.Testing
examples/start-ssr/test/ssr-inline.mjs, in the style ofdedupe.mjs, wired into the example'stestscript. It fails without the fix and passes 4/4 with it.dedupe.mjsstill passes 8/8.dist/esm/index.mjs. With the published plugin the seroval error appears 6 times over 3 requests; with this change it appears 0 times, the component renders in the SSR'd document, and the browser hydrates with no console errors.The existing
framesmode ofstart-ssrdoesn't reproduce the bug: its server components serializesc:livebefore the shell flushes. So the new test only checks the config; a runtime regression test would need a server component that resolves after the flush.🤖 Generated with Claude Code