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 was building some test scenarios and also one for long loading times with either a timeout or delayed response using MSW and maybe cam across something that does not sit with me well (this may be very well a skill issue 😅): Changing routes always waits on the Promise on the depending loader function to resolve/reject – even if a navigation event happens that would make fulfilling the Promise unnecessary.
I was wondering if aborting request could be done somehow implicitly by the router. So far I played around with AbortController and makeAbortable, but I'm a bit undecided on how and where exactly this could be managed. Would appreciate some thoughts on this (and whether or not it makes sense) 🤗
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I was building some test scenarios and also one for long loading times with either a timeout or delayed response using MSW and maybe cam across something that does not sit with me well (this may be very well a skill issue 😅): Changing routes always waits on the Promise on the depending loader function to resolve/reject – even if a navigation event happens that would make fulfilling the Promise unnecessary.
I was wondering if aborting request could be done somehow implicitly by the router. So far I played around with AbortController and makeAbortable, but I'm a bit undecided on how and where exactly this could be managed. Would appreciate some thoughts on this (and whether or not it makes sense) 🤗
Here is a minimal outline of the paths/setup:
Setup
Navigating patterns
Note
For the scenario we assume very long loading times for illustrative purpose (
> 4s
)Happy path
Begin on
/
(HomePage
)loadHomeData
(intent:initial
)/post/a
and load data vialoadPostData
(intent:preload
)/post/a
is done and cached/post/a
(PostPage
)Aborting unneeded requests
Begin on
/
(HomePage
)loadHomeData
(intent:initial
)/post/a
and load data vialoadPostData
(intent:preload
)/post/b
and load data vialoadPostData
(intent:preload
)/post/a
(PostPage
)/post/b
is aborted/post/a
is still pending<Suspense>
for relevant blocks and wait for data to settleNavigating away from unresolved loading within the same route
Begin on
/
(HomePage
)loadHomeData
(intent:initial
)/post/a
and load data vialoadPostData
(intent:preload
)/post/a
(PostPage
)<Suspense>
for relevant blocks and wait for data to settle/post/b
and load data vialoadPostData
(intent:preload
)/post/b
(PostPage
)/post/b
is still pending/
(HomePage
) and load data via load functionloadHomeData
(intent:navigate
)Caution
Currently navigation to
/
is done after the Promise form the loaded has been resolved/rejected. Ideally this would exit early, when navigating away.HomePage
Beta Was this translation helpful? Give feedback.
All reactions