Skip to content

fix: reject server function calls on 5xx responses without X-Error - #2261

Open
adipascu wants to merge 1 commit into
solidjs:mainfrom
adipascu:fix/server-fn-5xx-rejection-v2
Open

fix: reject server function calls on 5xx responses without X-Error#2261
adipascu wants to merge 1 commit into
solidjs:mainfrom
adipascu:fix/server-fn-5xx-rejection-v2

Conversation

@adipascu

@adipascu adipascu commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

Server function calls only reject when the response carries an X-Error header. Two cases slip past that check in packages/start/src/fns/client.ts:

  • A 5xx produced below the handler (a server function module crashing at import time, a proxy or CDN error, a dead worker) has no X-Error, so the promise resolves and callers mistake server failure for success.
  • An error response whose body yields nothing throws undefined, so callers have no error to inspect or match on.

Minimal reproduction: https://github.com/adipascu/solid-start-server-fn-500-repro

What is the new behavior?

Responses with status >= 500 throw the deserialized result the same way X-Error does, falling back to an Error carrying the status when the body yields nothing. 4xx responses are untouched, since server functions can legitimately return them without X-Error.

Other information

This is the follow-up to #2159, which was merged onto 1.x where I asked whether to retarget it at main. v2's rewritten client has the same logic, so the same fix applies.

Added packages/start/src/fns/client.spec.ts beside the existing handler.spec.ts. Both regression tests were confirmed to fail without the source change.

@netlify

netlify Bot commented Jul 28, 2026

Copy link
Copy Markdown

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

Name Link
🔨 Latest commit f0db21f
🔍 Latest deploy log https://app.netlify.com/projects/solid-start-landing-page/deploys/6a68da943d757500081285d5
😎 Deploy Preview https://deploy-preview-2261--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.

@changeset-bot

changeset-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f0db21f

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

@pkg-pr-new

pkg-pr-new Bot commented Jul 28, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: f0db21f

@adipascu
adipascu force-pushed the fix/server-fn-5xx-rejection-v2 branch from 749f1af to 66f3088 Compare July 28, 2026 15:49
@adipascu
adipascu marked this pull request as ready for review July 28, 2026 16:27
@adipascu
adipascu force-pushed the fix/server-fn-5xx-rejection-v2 branch from 66f3088 to f0db21f Compare July 28, 2026 16:36
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.

1 participant