File tree Expand file tree Collapse file tree
packages/core/src/resource Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -421,7 +421,7 @@ export class ResourceImpl<T, R> extends BaseWritableResource<T> implements Resou
421421 // The actual loading is run through `untracked` - only the request side of `resource` is
422422 // reactive. This avoids any confusion with signals tracking or not tracking depending on
423423 // which side of the `await` they are.
424- const stream = untracked ( ( ) => {
424+ const loaderResult = untracked ( ( ) => {
425425 return this . loaderFn ( {
426426 params : extRequest . request as Exclude < R , undefined > ,
427427 abortSignal,
@@ -435,30 +435,18 @@ export class ResourceImpl<T, R> extends BaseWritableResource<T> implements Resou
435435 // matches this load, then we should ignore this resolution.
436436 const shouldDiscard = ( ) => abortSignal . aborted || untracked ( this . extRequest ) !== extRequest ;
437437
438- if ( isSignal ( stream ) ) {
439- if ( shouldDiscard ( ) ) {
440- return ;
441- }
442-
443- this . state . set ( {
444- extRequest,
445- status : 'resolved' ,
446- previousStatus : 'resolved' ,
447- stream,
448- } ) ;
449- } else {
450- const resolvedStream = await stream ;
451- if ( shouldDiscard ( ) ) {
452- return ;
453- }
438+ const stream = isSignal ( loaderResult ) ? loaderResult : await loaderResult ;
454439
455- this . state . set ( {
456- extRequest,
457- status : 'resolved' ,
458- previousStatus : 'resolved' ,
459- stream : resolvedStream ,
460- } ) ;
440+ if ( shouldDiscard ( ) ) {
441+ return ;
461442 }
443+
444+ this . state . set ( {
445+ extRequest,
446+ status : 'resolved' ,
447+ previousStatus : 'resolved' ,
448+ stream,
449+ } ) ;
462450 } catch ( err ) {
463451 rethrowFatalErrors ( err ) ;
464452 if ( abortSignal . aborted || untracked ( this . extRequest ) !== extRequest ) {
You can’t perform that action at this time.
0 commit comments