Skip to content

fix(fns): guard the no-JS flash cookie against non-form arguments - #2320

Merged
brenelz merged 3 commits into
mainfrom
fix/nojs-crash
Sep 18, 2026
Merged

brenelz merged 3 commits into
mainfrom
fix/nojs-crash

Conversation

@lxsmnsyc

Copy link
Copy Markdown
Member

A no-JS server function POST with an empty or non-form body returned a 500. The
flash cookie called .entries() on an argument that was not a FormData and
threw, and the same code runs as the error handler, so it rethrew and the
request died.

Changes:

  • Spread .entries() only when the last argument is a FormData.
  • Wrap the flash cookie build so a bad value degrades to a plain redirect.
  • Add regression tests for a non-form body, an empty body, and the form case.

An unauthenticated no-JS POST with an empty or non-form body left `undefined`
(or another non-FormData value) as the last parsed argument. Building the
flash cookie called `.entries()` on it and threw. handleNoJS is also the
catch-path error handler, so it rethrew on the same input and the request
died with a 500.

- Only spread `.entries()` when the last argument actually is a FormData;
  otherwise pass the value through.
- Wrap the flash cookie construction so an unserializable value degrades to a
  plain redirect instead of throwing out of the error handler.
- Add regression tests for a non-form body, an empty body, and the form case.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Sep 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d3c094f

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

This PR includes changesets to release 1 package
Name Type
@solidjs/start 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

@netlify

netlify Bot commented Sep 16, 2026

Copy link
Copy Markdown

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

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

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@pkg-pr-new

pkg-pr-new Bot commented Sep 16, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@solidjs/start@2320

commit: d3c094f

@brenelz

brenelz commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Review

Intent: No-JS server function POSTs with empty/non-form bodies were 500ing because the flash cookie build called .entries() on a non-FormData last arg — and that same path is the error handler, so it rethrew. Guarding the entries call and wrapping cookie serialize in try/catch is the right shape.

Verdict: No blockers. Already approved; leaving the written notes here.

Blockers

None. CI green.

Nits

  1. Duck-type last?.entries — correctly covers both FormData and URLSearchParams (urlencoded goes through extractBody as the latter). Prefer instanceof FormData || instanceof URLSearchParams so a stray Array/Map doesn’t get turned into index pairs. Unlikely on this path, but clearer.
  2. Tests cover non-form, empty, and form echo — good. Optional: on the crash cases, assert there is no flash= Set-Cookie (or that input is empty) so the “best effort” path stays honest.

What’s strong

  • Root cause matches the code; try/catch correctly protects the redirect/error path.
  • Changeset scoped to @solidjs/start.
  • Regression tests hit the real no-JS gate (no X-Server-Instance).

Brenley Dueck and others added 2 commits September 17, 2026 20:35
@brenelz
brenelz merged commit 048f5a9 into main Sep 18, 2026
13 checks passed
@brenelz
brenelz deleted the fix/nojs-crash branch September 18, 2026 01:39
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.

2 participants