Skip to content

Commit 4345c9c

Browse files
committed
test(executor): pin the subflow aggregate spill cutoff to the exact byte
1 parent d99e2bc commit 4345c9c

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎apps/sim/lib/execution/payloads/serializer.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,23 @@ describe('compactExecutionPayload', () => {
303303
expect(compacted.every(isLargeArrayManifest)).toBe(true)
304304
})
305305

306+
it('spills subflow results once their aggregate is one byte over the threshold', async () => {
307+
const results = () => [{ text: 'é"\\'.repeat(5) }, undefined, [1, null], 'plain']
308+
const bytes = Buffer.byteLength(JSON.stringify({ results: results() }), 'utf8')
309+
310+
const fitting = await compactSubflowResults(results(), {
311+
thresholdBytes: bytes,
312+
...TEST_EXECUTION_CONTEXT,
313+
})
314+
expect(fitting).toEqual(results())
315+
316+
const over = await compactSubflowResults(results(), {
317+
thresholdBytes: bytes - 1,
318+
...TEST_EXECUTION_CONTEXT,
319+
})
320+
expect(over.map((result) => isLargeValueRef(result))).toEqual([true, false, true, true])
321+
})
322+
306323
it('reuses already-compacted subflow entries instead of rebuilding them', async () => {
307324
const unchanged = { rows: [{ id: 1, data: { name: 'a' } }], meta: { count: 1 } }
308325
const file = { id: 'f1', key: 'k1', url: 'u', name: 'a.txt', size: 3, type: 'text/plain' }

0 commit comments

Comments
 (0)