query icon indicating copy to clipboard operation
query copied to clipboard

Throw-on-server-default-fix

Open buddamus opened this issue 1 year ago • 5 comments

fix: stop defaulting to throwOnError=true when isServer===true so that SSR can render the page the same way the client will rather than showing the error boundary fallback

buddamus avatar Aug 25 '24 14:08 buddamus

fix: stop defaulting to throwOnError=true when isServer===true so that SSR can render the page the same way the client will rather than showing the error boundary fallback

it's on purpose that we also throw errors on the server because what react will then do during SSR is render the Suspense fallback (not the error) and retry automatically on the client. The error boundary will only be shown once that fails, too.

TkDodo avatar Aug 26 '24 07:08 TkDodo

@TkDodo My code change was not for react, but for solid (hence my changes are in packages/solid-query/src/createBaseQuery.ts).

What I am seeing is the server returns a page with the error boundary displayed. With the changes from this PR, the server sends exactly what I expected and still does the retry as you mentioned. I would prefer the server to not send with the error boundary and reserve the error boundary for unexpected errors. In my scenario, a fetch call is failing. I am manually handling this error with proper state management so it makes sense to me that the sever respects what my code is doing and serves the page just like the client would.

buddamus avatar Aug 26 '24 13:08 buddamus

right, maybe solid is different to react here. @ardeora FYI

TkDodo avatar Aug 26 '24 13:08 TkDodo

☁️ Nx Cloud Report

CI is running/has finished running commands for commit cfe8a00494e4df90b1160e7734a12944eee03227. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


🟥 Failed Commands
nx affected --targets=test:sherif,test:knip,test:eslint,test:lib,test:types,test:build,build --parallel=3
✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

nx-cloud[bot] avatar Aug 26 '24 13:08 nx-cloud[bot]

commit: cfe8a00

@tanstack/angular-query-devtools-experimental

pnpm add https://pkg.pr.new/@tanstack/angular-query-devtools-experimental@7952
@tanstack/angular-query-experimental

pnpm add https://pkg.pr.new/@tanstack/angular-query-experimental@7952
@tanstack/eslint-plugin-query

pnpm add https://pkg.pr.new/@tanstack/eslint-plugin-query@7952
@tanstack/query-async-storage-persister

pnpm add https://pkg.pr.new/@tanstack/query-async-storage-persister@7952
@tanstack/query-broadcast-client-experimental

pnpm add https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@7952
@tanstack/query-core

pnpm add https://pkg.pr.new/@tanstack/query-core@7952
@tanstack/query-devtools

pnpm add https://pkg.pr.new/@tanstack/query-devtools@7952
@tanstack/query-persist-client-core

pnpm add https://pkg.pr.new/@tanstack/query-persist-client-core@7952
@tanstack/query-sync-storage-persister

pnpm add https://pkg.pr.new/@tanstack/query-sync-storage-persister@7952
@tanstack/react-query

pnpm add https://pkg.pr.new/@tanstack/react-query@7952
@tanstack/react-query-devtools

pnpm add https://pkg.pr.new/@tanstack/react-query-devtools@7952
@tanstack/react-query-next-experimental

pnpm add https://pkg.pr.new/@tanstack/react-query-next-experimental@7952
@tanstack/react-query-persist-client

pnpm add https://pkg.pr.new/@tanstack/react-query-persist-client@7952
@tanstack/solid-query

pnpm add https://pkg.pr.new/@tanstack/solid-query@7952
@tanstack/solid-query-devtools

pnpm add https://pkg.pr.new/@tanstack/solid-query-devtools@7952
@tanstack/solid-query-persist-client

pnpm add https://pkg.pr.new/@tanstack/solid-query-persist-client@7952
@tanstack/svelte-query

pnpm add https://pkg.pr.new/@tanstack/svelte-query@7952
@tanstack/svelte-query-devtools

pnpm add https://pkg.pr.new/@tanstack/svelte-query-devtools@7952
@tanstack/svelte-query-persist-client

pnpm add https://pkg.pr.new/@tanstack/svelte-query-persist-client@7952
@tanstack/vue-query

pnpm add https://pkg.pr.new/@tanstack/vue-query@7952
@tanstack/vue-query-devtools

pnpm add https://pkg.pr.new/@tanstack/vue-query-devtools@7952

Open in Stackblitz

More templates

pkg-pr-new[bot] avatar Aug 26 '24 13:08 pkg-pr-new[bot]