Skip to content

fix: replace pagination with createdBeforeOrAt keyset#2094

Merged
dwjanus merged 1 commit intomainfrom
dwj/eng-1927-dep-pagination-in-sub-fills
Mar 11, 2026
Merged

fix: replace pagination with createdBeforeOrAt keyset#2094
dwjanus merged 1 commit intomainfrom
dwj/eng-1927-dep-pagination-in-sub-fills

Conversation

@dwjanus
Copy link
Contributor

@dwjanus dwjanus commented Mar 9, 2026

Changes

Switch requestAllAccountFills from page-based to keyset pagination

  • Replace parallel page-number pagination with sequential createdBeforeOrAt cursor pagination to reduce indexer load
  • Use the createdAt timestamp of the last fetched fill as the cursor for each subsequent request
  • Deduplicate fills by id to handle inclusive boundary overlaps across pages
  • No changes to the public API — callers receive the same sorted RawSubaccountFill[]

Issue

ENG-1927

@dwjanus dwjanus requested a review from a team as a code owner March 9, 2026 20:44
@linear
Copy link

linear bot commented Mar 9, 2026

@vercel
Copy link

vercel bot commented Mar 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
v4-staging Ready Ready Preview, Comment Mar 11, 2026 2:15pm
v4-testnet Ready Ready Preview, Comment Mar 11, 2026 2:15pm

Request Review

}

const allFills: RawSubaccountFill[] = [...fills, ...results.map((data) => data.fills).flat()];
const newFills = fills.filter((fill: RawSubaccountFill) => !seenIds.has(fill.id));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the createdBeforeOrAt as a keyset not 100% reliable? as in we could still get overlap of fills between sequential requests?

const seenIds = new Set<string>();

for (let request = 0; request < DEFAULT_MAX_REQUESTS; request += 1) {
const createdBeforeOrAt = allFills.at(-1)?.createdAt ?? undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?? undefined is redundant here prob

@dwjanus dwjanus force-pushed the dwj/eng-1927-dep-pagination-in-sub-fills branch from be50a7b to 32d905d Compare March 11, 2026 14:09
@dwjanus dwjanus merged commit 3432a62 into main Mar 11, 2026
14 checks passed
@dwjanus dwjanus deleted the dwj/eng-1927-dep-pagination-in-sub-fills branch March 11, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants