From 30501d91d54e15cf639abf3484639ec490c803fc Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Mon, 12 Oct 2026 13:07:01 -0700 Subject: [PATCH] fix(tests): cross the large-array threshold with 64 wide rows instead of 120k The durable-manifest test built 120,000 small rows (~16 MB). Compaction walks every element (a promise, Object.entries and JSON.stringify per row and per field), so the test ran 575-1522 ms on healthy CI runners and 10.6 s on a contended one, timing out. 64 rows whose payloads sum to LARGE_VALUE_THRESHOLD_BYTES cross the same threshold with the same assertions; the 9 MB string tests beside it run in ~50 ms. --- .../lib/function-execution/execute-request.test.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/sim/lib/function-execution/execute-request.test.ts b/apps/sim/lib/function-execution/execute-request.test.ts index 653af53e30b..bacf6bb0c47 100644 --- a/apps/sim/lib/function-execution/execute-request.test.ts +++ b/apps/sim/lib/function-execution/execute-request.test.ts @@ -172,7 +172,10 @@ vi.mock('@/lib/function-execution/sandbox-mounts', () => ({ import { validateExternalUrl } from '@/lib/core/security/input-validation' import { clearLargeValueCacheForTests } from '@/lib/execution/payloads/cache' import { isLargeArrayManifest } from '@/lib/execution/payloads/large-array-manifest-metadata' -import { isLargeValueRef } from '@/lib/execution/payloads/large-value-ref' +import { + isLargeValueRef, + LARGE_VALUE_THRESHOLD_BYTES, +} from '@/lib/execution/payloads/large-value-ref' import * as fileMaterialization from '@/lib/execution/payloads/materialization.server' import { executeFunctionRequest } from '@/lib/function-execution/execute-request' import { ResolvedSecretTraceRegistry } from '@/executor/utils/resolved-secret-trace-registry' @@ -820,11 +823,13 @@ describe('Function execution request', () => { describe('Basic Function Execution', () => { it('compacts large array result fields to manifests when execution context is durable', async () => { + // Compaction cost scales with element count, so a few wide rows cross the threshold cheaply. + const rowCount = 64 mockExecuteInIsolatedVM.mockResolvedValueOnce({ result: { - rows: Array.from({ length: 120_000 }, (_, index) => ({ + rows: Array.from({ length: rowCount }, (_, index) => ({ key: `SIM-${index}`, - payload: 'x'.repeat(100), + payload: 'x'.repeat(LARGE_VALUE_THRESHOLD_BYTES / rowCount), })), }, stdout: '', @@ -846,7 +851,7 @@ describe('Function execution request', () => { expect(data.output.result.rows).toMatchObject({ __simLargeArrayManifest: true, kind: 'array', - totalCount: 120_000, + totalCount: rowCount, }) })