Skip to content

Commit 19eeab6

Browse files
committed
test(plugin-approvals): seed the #37808 stranded-scan cases in batches, not 1200 serial inserts
The "older strand outside the newest window" case seeded 1201 rows with one engine insert each; that seeding was ~90% of the case's ~1 s locally and 5.8-13 s on loaded merge-queue runners, past the 5 s test default, so it ejected unrelated PRs from the queue. The rows now go through the engine's own array insert, 200 rows per batch (SQLite refuses a multi-row INSERT past its 500-term compound SELECT). Rows, order and every assertion are unchanged; the 600-row case additionally asserts all 601 rows are read. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgVv7fqmna3sqqbjzf2
1 parent ccdfe62 commit 19eeab6

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎packages/plugins/plugin-approvals/src/stranded-request-inspection.test.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,8 +795,17 @@ describe('#37808 — past 500 decided requests, a new strand is still reported',
795795
svc.attachAutomation(surface(strandedRuns) as any);
796796
return svc;
797797
};
798+
// [#38223] Seeded in batches through the engine's own array insert, not one
799+
// `insert` per row: 1200 serial single-row writes were ~90% of the slowest
800+
// case's ~1 s locally and 5.8–13 s on loaded merge-queue runners, past the
801+
// 5 s test default. The rows, their order and every assertion are unchanged;
802+
// the batch is ≤ 200 rows because SQLite refuses a multi-row INSERT past its
803+
// 500-term compound SELECT limit.
804+
const SEED_BATCH = 200;
798805
const insertAll = async (rows: FakeRow[]) => {
799-
for (const row of rows) await engine.insert('sys_approval_request', row, { context: { isSystem: true } } as any);
806+
for (let i = 0; i < rows.length; i += SEED_BATCH) {
807+
await engine.insert('sys_approval_request', rows.slice(i, i + SEED_BATCH), { context: { isSystem: true } } as any);
808+
}
800809
};
801810

802811
// A fresh in-memory store per test: each one counts rows from zero.
@@ -837,6 +846,8 @@ describe('#37808 — past 500 decided requests, a new strand is still reported',
837846
// The newest decision: its run is gone.
838847
await insertAll([decided(++seq, { flow_run_id: 'run_new_strand' })]);
839848
const out = await freshService(['run_new_strand']).inspectStrandedRequests();
849+
// Newest window (ids 102–601) plus the first walk page (ids 1–500): every one of the 601 seeded rows is read.
850+
expect(out.scanned).toBe(601);
840851
expect(out.stranded.map(s => s.runId)).toEqual(['run_new_strand']);
841852
});
842853

0 commit comments

Comments
 (0)