You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I originally thought this was an issue with the <Await> component, but I've since realized that the underlying behavioral change is with serverLoader(), and I assume by extension turbo-stream
With v3_singleFetch enabled, a redirect Response received from serverLoader() should result in a rejected Promise.
Actual Behavior
With v3_singleFetch enabled, a redirect Response received from serverLoader() results in a resolved Promise.
When used with <Await>, note that the Response instance is passed to the children function if provided, which breaks the type contract for <Await>:
exportfunctionloader(){if(someCondition){throwredirect('/');}return{foo: 'bar',};}exportfunctionclientLoader({ serverLoader }: ClientLoaderFunctionArgs){return{promise: serverLoader<typeofloader>(),}}clientLoader.hydrate=true;exportdefaultfunctionRouteComponent(){const{ promise }=useLoaderData<typeofclientLoader>();return(<Suspensefallback={<>Loading...</>}><Awaitresolve={promise}>{/* Here, the typings say that data is of type `{ foo: string }`, but at runtime if `someCondition` is true it will be a `Response` instance with a 302 status and `Location` header. */}{(data)=><Renderdata={data}/>}</Await></Suspense>);}
The text was updated successfully, but these errors were encountered:
rossipedia
changed the title
<Await> handling of redirects changes with Single Fetch
handling of redirects encountered in serverLoader changes with Single Fetch
Nov 11, 2024
We just published version 2.15.2-pre.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!
Reproduction
https://github.com/rossipedia/await-single-fetch-shenanigans
https://stackblitz.com/~/rossipedia/await-single-fetch-shenanigans
System Info
Used Package Manager
npm
Expected Behavior
Note
I originally thought this was an issue with the
<Await>
component, but I've since realized that the underlying behavioral change is withserverLoader()
, and I assume by extensionturbo-stream
With
v3_singleFetch
enabled, a redirectResponse
received fromserverLoader()
should result in a rejectedPromise
.Actual Behavior
With
v3_singleFetch
enabled, a redirectResponse
received fromserverLoader()
results in a resolvedPromise
.When used with
<Await>
, note that theResponse
instance is passed to thechildren
function if provided, which breaks the type contract for<Await>
:The text was updated successfully, but these errors were encountered: