From 960851642238af6208a6d2080354166b2895b818 Mon Sep 17 00:00:00 2001 From: Michael Gilardi <11632652+mgilardi@users.noreply.github.com> Date: Mon, 23 Nov 2026 07:22:39 -0700 Subject: [PATCH] Stop paginating finds that can run inside a transaction A paginated find makes Payload's Mongo adapter send the find and its count at once on the request's session. When that is the first query in a transaction, the two race to start it and one fails with NoSuchTransaction (about 1 in 7 in the positions plugin, where it was found). These finds only use the rows, so pagination: false drops the count and the race; any limit still applies. Lists that page for people (a page argument, totals returned) are left as they are. They run outside any transaction. Tested: typecheck and the full suite. The race itself isn't reproduced here; Whitehat's lint is meant to catch new cases. Task: K708 Co-Authored-By: Claude Opus 5.5 --- src/fulfil.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fulfil.ts b/src/fulfil.ts index a19c49a..95e6c9f 100644 --- a/src/fulfil.ts +++ b/src/fulfil.ts @@ -15,7 +15,7 @@ const scopeWhere = (o: ResolvedSupplies, scope: ID | null): Where[] => (o.scopeF async function readyUnits(payload: Payload, o: ResolvedSupplies, req: Req, recipe: Doc, limit: number) { const where: Where = { and: [{ recipe: { equals: recipe.id } }, { status: { equals: 'ready' } }, ...scopeWhere(o, o.scopeField ? idOf(recipe[o.scopeField]) : null)] } - return (await payload.find({ collection: o.units as CollectionSlug, where, sort: ['builtAt', 'id'], limit, pagination: true, ...sys, joins: false, req })).docs as Doc[] + return (await payload.find({ collection: o.units as CollectionSlug, where, sort: ['builtAt', 'id'], limit, pagination: false, ...sys, joins: false, req })).docs as Doc[] } const setUnit = (payload: Payload, o: ResolvedSupplies, req: Req, id: ID, data: Doc) =>