From 4bfc136773327eb11c5e8124ff46eb2fdab99115 Mon Sep 17 00:00:00 2001
From: Claude
Date: Tue, 17 Nov 2026 05:54:15 +0000
Subject: [PATCH] fix: render a no-JS form post's outcome inline (#724)
The flash decode suspended under the app's , so the shell flushed
the fallback and the outcome only streamed as a that a browser
without JavaScript never swaps in. Root now reads submissions on the
server before the app's root renders, so the decode holds the shell.
Co-Authored-By: Claude Opus 5.5
Claude-Session: https://claude.ai/code/session_0117BoWKegJTJmg5nmox4u4v
---
.changeset/no-js-flash-inline.md | 5 ++
src/routers/components.tsx | 9 +++
src/routing.ts | 3 +-
test/server/flash-no-js-inline.spec.tsx | 93 +++++++++++++++++++++++++
4 files changed, 109 insertions(+), 1 deletion(-)
create mode 100644 .changeset/no-js-flash-inline.md
create mode 100644 test/server/flash-no-js-inline.spec.tsx
diff --git a/.changeset/no-js-flash-inline.md b/.changeset/no-js-flash-inline.md
new file mode 100644
index 00000000..ce37d28d
--- /dev/null
+++ b/.changeset/no-js-flash-inline.md
@@ -0,0 +1,5 @@
+---
+"@solidjs/router": patch
+---
+
+Render a no-JS form post's outcome inline (#724). The page a no-JS submission redirects back to decodes the flash cookie asynchronously; that read suspended under the app's ``, so the shell flushed the fallback and the form and its error arrived only as a streamed `` a browser without JavaScript never swaps in. The router now reads submissions at its root on the server, so the decode holds the shell instead. No client bundle change.
diff --git a/src/routers/components.tsx b/src/routers/components.tsx
index 0c8d2f61..f84a1d08 100644
--- a/src/routers/components.tsx
+++ b/src/routers/components.tsx
@@ -37,6 +37,15 @@ export function Root(props: {
preload?: RoutePreloadFunc;
children: JSX.Element;
}) {
+ // A no-JS form post lands back here on a GET carrying the flash cookie,
+ // and that browser cannot swap streamed chunks in. Read the
+ // submissions above the app's root (and so above any of its
+ // boundaries) so the flash decode suspends this root slot, which holds the
+ // shell, instead of a boundary that would flush its fallback (#724). Runs
+ // before anything is created so the retry starts clean; a request with no
+ // flash cookie seeds [] without suspending. Server-only: folds out of
+ // client bundles.
+ isServer && props.routerState.submissions[0]();
const location = props.routerState.location;
const params = props.routerState.params;
const data = createMemo(
diff --git a/src/routing.ts b/src/routing.ts
index d76a94e3..36c045eb 100644
--- a/src/routing.ts
+++ b/src/routing.ts
@@ -861,7 +861,8 @@ export function createRouterContext(
// malformed-cookie semantics. Created only when a flash cookie actually
// arrived (server-only by construction: `flash` is only ever set there), and
// - `lazy`: server memos compute eagerly by default — deferred to first
- // read, a request whose submissions are never read never decodes;
+ // read, which `Root` makes on every server render (#724), so the
+ // decode suspends the root slot rather than an app boundary;
// - `transparent`: the memo exists on the server only, so its owner
// must not consume a hydration-id slot — the client, which seeds
// submissions as [] without ever creating this memo, would miss it
diff --git a/test/server/flash-no-js-inline.spec.tsx b/test/server/flash-no-js-inline.spec.tsx
new file mode 100644
index 00000000..7d3c88ba
--- /dev/null
+++ b/test/server/flash-no-js-inline.spec.tsx
@@ -0,0 +1,93 @@
+// #724: a no-JS round trip lands on a GET carrying the flash cookie. The
+// browser has no runtime to swap out-of-order chunks in, so the
+// flash outcome must render inline in the shell — the decode (WebCrypto,
+// async) holds the shell instead of suspending the route under a fallback.
+import { For, Loading, createMemo } from "solid-js";
+import { createRequestEvent, renderToStream } from "@solidjs/web";
+import { provideRequestEvent } from "@solidjs/web/storage";
+import { decodeFlashCookie, encodeFlashCookie } from "@solidjs/web/server-functions/server";
+import { formAction, useSubmissions } from "../../src/data/action.js";
+import { provideFlashDecoder } from "../../src/routing.js";
+import { createRouter, query } from "../../src/index.js";
+
+const getTodos = query(async () => ["first"], "todos-inline");
+
+(globalThis as any).__SOLID_SECRET__ = "flash-no-js-inline-spec-secret";
+
+const save = formAction(
+ Object.assign(
+ async () => {
+ throw new Error("unused");
+ },
+ { url: "/_server/save-inline" }
+ )
+);
+
+const delay = (ms: number) => new Promise(r => setTimeout(r, ms));
+
+// The decode is WebCrypto: its latency is the platform's, not a microtask.
+// A few timer turns is enough to outlast the stream's shell drain.
+provideFlashDecoder(async cookieHeader => {
+ await delay(30);
+ return decodeFlashCookie(cookieHeader);
+});
+
+describe("no-JS flash outcome renders inline (#724)", () => {
+ test("a submissions read under the root Loading is in the shell, not a streamed template", async () => {
+ function Page() {
+ const subs = useSubmissions(save);
+ const list = createMemo(() => getTodos());
+ return (
+
+
+
+ {(subs.at(-1)?.error as any)?.issues?.title}
+
+ );
+ }
+ const Router = createRouter({ routes: [{ path: "/", component: Page }] });
+
+ const cookie = (await encodeFlashCookie(
+ "/_server/save-inline",
+ { issues: { title: "Too short" } },
+ [],
+ true
+ ))!;
+ const event = createRequestEvent(
+ new Request("http://localhost/", { headers: { cookie: cookie.split(";")[0] } })
+ );
+ // pipe, not `.then(String)`: awaiting the whole stream renders every
+ // boundary inline, which hides exactly what a no-JS browser is sent first
+ const shell = await provideRequestEvent(
+ event,
+ () =>
+ new Promise(resolve => {
+ renderToStream(() => (
+
+
+
+
+ {props => (
+ loading
}>{props.children}
+ )}
+
+
+
+ )).pipe({
+ write(chunk: string) {
+ resolve(String(chunk));
+ },
+ end() {}
+ });
+ })
+ );
+ const html = shell;
+ expect(html).not.toContain('class="fallback"');
+ expect(html).toContain("