From 1c40e5b7b01dcf6346f6373db8c760383e1ffdea Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Mon, 5 Oct 2026 21:11:21 -0400 Subject: [PATCH] Push operation rows in a loop, not a spread Spreading a large RETURNING * result into push() overflowed the call stack on scale, recode and clone. Co-Authored-By: Claude Sonnet 5.5 --- routes/operations.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/routes/operations.js b/routes/operations.js index d1ee846..4d901be 100644 --- a/routes/operations.js +++ b/routes/operations.js @@ -905,7 +905,7 @@ module.exports = function(pool) { for (const unit of units) { const incr = await resolveIncrs(client, ctx, unit.where, excludeClause, req.body); // no rows, or already at the target — nothing to write for this slice - if (incr.value === 0 && incr.units === 0) { skipped.push(...unit.slices); continue; } + if (incr.value === 0 && incr.units === 0) { for (const s of unit.slices) skipped.push(s); continue; } applied++; const loggedSlice = unit.slices.length === 1 ? unit.slices[0] : unit.slices; @@ -933,7 +933,7 @@ module.exports = function(pool) { for (const r of result.rows) { if (r.pf_logid != null) sqlByLogId.set(r.pf_logid, sql); } - allRows.push(...result.rows); + for (const r of result.rows) allRows.push(r); } if (allRows.length === 0) { @@ -1041,7 +1041,7 @@ module.exports = function(pool) { for (const r of result.rows) { if (r.pf_logid != null) sqlByLogId.set(r.pf_logid, sql); } - allRows.push(...result.rows); + for (const r of result.rows) allRows.push(r); } // Every coordinate in the selection nets to zero -- nothing to move. // Refused like scale's no-op rather than committing an empty log @@ -1161,7 +1161,7 @@ module.exports = function(pool) { for (const r of result.rows) { if (r.pf_logid != null) sqlByLogId.set(r.pf_logid, sql); } - allRows.push(...result.rows); + for (const r of result.rows) allRows.push(r); } await client.query('COMMIT'); committed = true;