react-query's fetchNextPage cancels a next page still loading and sends it again by default.
Our requests ignore the abort signal, so the server ran both: the feed's read-ahead effect
re-runs on scroll frames before isFetchingNextPage reaches it, and on prod every feed page
went out 2-3 times (a 0.8 s title sort queued to 2.3 s). Every call now passes NEXT_PAGE
({cancelRefetch: false}), lint-enforced, with a contract test.
10 lines
651 B
TypeScript
10 lines
651 B
TypeScript
/**
|
||
* What every `fetchNextPage` call passes (lint-enforced). By default react-query CANCELS a next-page
|
||
* fetch that is still in flight and sends it again with the same cursor. Our requests do not take the
|
||
* abort signal, so the first one is not stopped: the server ran both. The feed's read-ahead effect
|
||
* re-runs on every scroll frame, and a frame that lands before `isFetchingNextPage` turns true calls
|
||
* again. On prod (E31 S4e) every feed page went out 2–3 times; on a 0.8 s title sort the copies
|
||
* queued to 2.3 s. With this a second call joins the fetch already running.
|
||
*/
|
||
export const NEXT_PAGE = { cancelRefetch: false } as const;
|