Skip to content

Commit cad25fb

Browse files
fixup! Feat: nexchange plugin
Track every row consumed across cursor and offset pages so the offset fallback resumes after the cursor-fetched pages instead of re-requesting them. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 853a52c commit cad25fb

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/partners/nexchange.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ export async function queryNexchange(
309309
const txByOrderId: Map<string, StandardTx> = new Map()
310310
let cursor: string | undefined
311311
let offset = 0
312+
// Rows consumed so far, including pages fetched by cursor. Offset paging must
313+
// resume from this count, otherwise falling back from a cursor would re-request
314+
// pages that were already consumed.
315+
let fetchedCount = 0
312316

313317
try {
314318
// The currency catalog supplies the network/contract metadata that the
@@ -339,6 +343,7 @@ export async function queryNexchange(
339343
}
340344
const json = await response.json()
341345
const { orders, nextCursor, hasMore } = asNexchangeOrdersResponse(json)
346+
fetchedCount += orders.length
342347

343348
for (const rawOrder of orders) {
344349
const standardTx = processNexchangeTx(rawOrder, currencyMap)
@@ -358,7 +363,7 @@ export async function queryNexchange(
358363
// cursor value would re-pin pagination to the wrong position next
359364
// iteration.
360365
cursor = undefined
361-
offset += orders.length
366+
offset = fetchedCount
362367
}
363368
}
364369
} catch (e) {

0 commit comments

Comments
 (0)