Cache nearby locations for local pagination - #618
Conversation
There was a problem hiding this comment.
Not safe to approve. The PR introduces risky pagination/cache behavior changes with at least one likely functional regression and missing coverage for critical paths.
Blocking issues
- Likely pagination metadata regression:
use-cached-locations-paginationstorescachedDataset.numberOfPagesfrom/api/locations-paginationresponses fetched withpageSize=200, then UI pager uses that value as display-page bounds. If backendnumberOfPagesis computed from requestedpageSize, pager bounds will shrink by ~10x and disable navigation early (files:src/components/use-cached-locations-pagination.ts,src/components/locations-container.tsx,src/app/api/locations-pagination/route.ts). - Input validation gap in new API route:
pageSizeaccepts0(parsePositiveIntegerallows>= 0), andMath.min(..., MAX_PAGE_SIZE)does not enforce a lower bound. This can propagate an invalid page size togetFullLocationData, with undefined/broken behavior under malformed requests (src/app/api/locations-pagination/route.ts). - Risky logic added without tests: no evidence of tests for cache split/merge correctness, page-boundary behavior, and pager integration while loading. Given the new client-side caching + background fetch + URL mutation flow, missing tests are a blocking regression risk.
|
Addressed the blocking feedback in
Verification rerun:
|
There was a problem hiding this comment.
I cannot safely approve this PR due to blocking risk in the new pagination path.
Blocking issues
src/app/api/locations-pagination/route.tsaccepts unboundedpageNumber(parseNonNegativeIntegeronly checks >=0). This allows arbitrarily large page offsets against upstream location queries, creating a resource-exhaustion/DoS risk. Add an upper bound (or reject out-of-range pages based on known max pages/resultCount).- Client pagination now depends on
window.history.pushStateinsrc/components/use-cached-locations-pagination.tsand reactiveuseSearchParamsupdates, but there are no integration tests covering URL/state sync, back/forward behavior, and pager correctness. This is risky logic with clear regression potential and should be covered before approval.
|
Addressed the latest blocking review in
Current verification:
The PR can still show |
There was a problem hiding this comment.
I found a blocking pagination-cache regression risk that makes this unsafe to approve as-is.
Blocking issues
- Potential infinite background refetch loop / request storm when result set exceeds API cap. The client prefetch loop in
src/components/use-cached-locations-pagination.tscomputesmissingBackgroundPagesfromnumberOfPagesand attempts to fetch all of them, but the API hard-rejectspageNumber > 100insrc/lib/locations-pagination-request.tsandsrc/app/api/locations-pagination/route.ts. Failed pages are removed fromloadingBackgroundPagesbut never marked terminal, so they remain "missing" and can be retried repeatedly on each effect run. This is a regression/perf risk and should be fixed by capping client prefetch to supported max page number (or treating 400-cap pages as permanently exhausted) and adding tests for this boundary behavior.
|
@doobneek1 Is this PR associated with a particular issue number? |
|
No. Just an observation i made after you told me that our location fetch is
constrained by a radius and then I also realized we reload whole UI when we
navigate through search results.
Hello ,
Please Let me know if you have any questions. I am looking forward to your
response.
_______________________
Sincerely, doobneek
Founder of doobneek.org - home to your finances. Only you should know your
worth.
they/them
(917) 767-4065 <9177674065>
…On Mon, Mar 9, 2026, 7:31 PM Jacob Beard ***@***.***> wrote:
*jbeard4* left a comment (streetlives/yourpeer.nyc#618)
<#618 (comment)>
@doobneek1 <https://github.com/doobneek1> Is this PR associated with a
particular issue number?
—
Reply to this email directly, view it on GitHub
<#618 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BITVLK5Y5AOFC6FWLXWSSDL4P5H4TAVCNFSM6AAAAACWMNFAI6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DAMRXGYYDAMBUGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
Addressed the remaining bot review points in
Verification:
|
Summary
?page=values does not rerun the full App Router data fetch flowVerification
npm run check-typesnpm run lint(existing repo warnings only)npm run buildwithNEXT_PUBLIC_GO_GETTA_PROD_URLandNEXT_PUBLIC_GOOGLE_MAPS_API_KEYset in the shell