-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(useInfiniteQuery): prevent error when pages is undefined #8134
base: main
Are you sure you want to change the base?
fix(useInfiniteQuery): prevent error when pages is undefined #8134
Conversation
how would that case happen please? can you please add a test case that fails on |
I have found when it happens, will push some code on the weekend. just some examples of when it can happen:
will put tests + fix typing for InfinteQuery (right now it assumes pages/pageParams always exist, probably we can assume pages can be undefined as well) |
this is a programming error; if you use
query cancellation will re-set to the previous state, and that might be a |
hey there, i recently opened a similar Q&A discussion where we see the same exact error logs on infinite queries. Trying it out to reproduce but I am still not sure how. But i can tell that we are not using infinite query data by using setQueryData` |
By following the logs, I created a list where the trace logs points to in the minified bundle. Maybe its helpful to create some sort of steps to reproduce. @sinasun @TkDodo
// specifically starts from here
function p(t,n){return(0,r(d[0]).useBaseQuery)(t,r(d[1]).InfiniteQueryObserver,n)}
C=_.getOptimisticResult(b);if(y.useSyncExternalStore(y.useCallback((function(t)...
function(e){return e.behavior=(0,r(d[6]).infiniteQueryBehavior)(),r(d[5])(r(d[0])(s.prototype),"getOptimisticResult",this).call(this,e)}}
o=this.createResult(e,t)
hasNextPage:(0,r(d[6]).hasNextPage)(t,c.data) That calls getNextPageParam is called function p(n,t){var o=t.pages,u=t.pageParams,l=o.length-1;return o.length>0?n.getNextPageParam(o[l],o,u[l],u):void 0} here is why i am lost because I am not sure how pages can be undefined or null based on checking the code in |
This address a very rare bug that happened few times to my users with useInfiniteQuery, where the pages was undefined in getNextPageParam function
should not break anything