Skip to content

Conversation

@lxsmnsyc
Copy link
Member

@lxsmnsyc lxsmnsyc commented Jan 4, 2026

Pretty straight forward. Adds an opt-in mode to use json mode (set by default) for seroval streaming, this is because the js stream is affected by CSP.

Also adds streaming support for client-to-server communication (except for url-encoded requests), assuming that the browser it comes from supports it.

@changeset-bot
Copy link

changeset-bot bot commented Jan 4, 2026

🦋 Changeset detected

Latest commit: db4c511

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

@netlify
Copy link

netlify bot commented Jan 4, 2026

Deploy Preview for solid-start-landing-page ready!

Name Link
🔨 Latest commit db4c511
🔍 Latest deploy log https://app.netlify.com/projects/solid-start-landing-page/deploys/695b47d1f940cb00083deb8b
😎 Deploy Preview https://deploy-preview-2042--solid-start-landing-page.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 4, 2026

Open in StackBlitz

npm i https://pkg.pr.new/solidjs/solid-start/@solidjs/start@2042
npm i https://pkg.pr.new/solidjs/solid-start/@solidjs/vite-plugin-nitro-2@2042

commit: db4c511

middleware?: string;
serialization?: {
// This only matters for server function responses
mode?: 'js' | 'json';
Copy link
Member Author

Choose a reason for hiding this comment

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

When possible, add a plugins option here that we can load into the serializer. The only problem is how do we bridge it from the config to the runtime (do we need a "runtime" config API?)

Copy link
Contributor

Choose a reason for hiding this comment

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

The non-magical way I could think of is to add this as an option to createHandler in entry-server.tsx 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

either that or an "entry" file for configs I suppose.

Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't we be able to set an environment variable, then use something like

const serialization = import.meta.env.VITE_SOLIDSTART_SERIALIZATION;
if (["js", "json"].includes(serialization ?? "js")) {
  // initialize seroval mode
} else if (serialization) {
  const [serializer, deserializer] = await import(serialization);
}

Copy link
Member Author

Choose a reason for hiding this comment

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

@atk Not exactly this API in mind. I'm not trying to override seroval, I'm more of trying to think of an idea to allow incorporating 3P seroval plugins

URLSearchParamsPlugin,
URLPlugin,
];
const MAX_SERIALIZATION_DEPTH_LIMIT = 64;
Copy link
Member Author

Choose a reason for hiding this comment

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

Seroval has a default limit of 1000, but that's because of my poor judgment. Will probably port this default back.

// TODO(Alexis): move to serializeToJSONStream
body: await serializeToJSONString(args),
// duplex: 'half',
// body: serializeToJSONStream(args),
Copy link
Member Author

Choose a reason for hiding this comment

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

bleeding edge. TypeScript doesn't have the duplex property defined yet so this one is invalid for now. On top of that, this doesn't actually "stream" as in the server responds immediately on request. What the browser does currently is buffer the entire stream then sends in bulk (technically speaking, duplex: half describes this behavior, duplex: full describes the desired behavior).

Once all browsers are ready for this (and also TypeScript), we can swap to duplex: full

});
} else if (contentType?.startsWith('application/json')) {
parsed = await event.request.json() as any[];
} else if (request.headers.has('x-serialized')) {
Copy link
Member Author

@lxsmnsyc lxsmnsyc Jan 4, 2026

Choose a reason for hiding this comment

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

  1. We no longer use the application/json mime type for seroval
  2. We wanted to distinguish seroval-based body from JSON body. Did I just add a new feature?

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.

4 participants