From d881462e670ac010c9467b7bfaee85d2d8e57cd6 Mon Sep 17 00:00:00 2001 From: MarkGus0 <153433026+MarkGus0@users.noreply.github.com> Date: Mon, 31 Aug 2026 16:07:39 +0000 Subject: [PATCH] fix(runtime): give sandbox boundary wait a time budget Poll waitForBoundaryRequest against a wall-clock deadline so loaded CI filesystem work can still emit sandbox_boundary_request before the helper gives up. Test-only; production runtime is unchanged. Fixes #4383 Generated-by: Cursor Co-authored-by: MarkGus0 --- .../tool-runtime-sandbox-boundary.test.ts | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/packages/runtime/src/__tests__/tool-runtime-sandbox-boundary.test.ts b/packages/runtime/src/__tests__/tool-runtime-sandbox-boundary.test.ts index 7e49760271..fb240bb362 100644 --- a/packages/runtime/src/__tests__/tool-runtime-sandbox-boundary.test.ts +++ b/packages/runtime/src/__tests__/tool-runtime-sandbox-boundary.test.ts @@ -17,7 +17,7 @@ * under the License. */ -import { deferred, nextId } from '@maka/core/test-only/async-primitives'; +import { deferred, nextId, waitFor } from '@maka/core/test-only/async-primitives'; import assert from 'node:assert/strict'; import { mkdtemp, mkdir, realpath, rm, symlink, writeFile } from 'node:fs/promises'; import { tmpdir } from 'node:os'; @@ -1077,10 +1077,22 @@ function header(cwd = process.cwd()): SessionHeader { async function waitForBoundaryRequest( events: SessionEvent[], ): Promise> { - for (let attempt = 0; attempt < 100; attempt += 1) { - const event = events.find((candidate) => candidate.type === 'sandbox_boundary_request'); - if (event?.type === 'sandbox_boundary_request') return event; - await new Promise((resolve) => setTimeout(resolve, 0)); - } - throw new Error('Sandbox boundary request was not emitted'); + let event: Extract | undefined; + await waitFor( + () => { + const candidate = events.find((entry) => entry.type === 'sandbox_boundary_request'); + if (candidate?.type === 'sandbox_boundary_request') { + event = candidate; + return true; + } + return false; + }, + { + timeoutMs: 5_000, + pollMs: 10, + message: 'Sandbox boundary request was not emitted', + }, + ); + assert.ok(event); + return event; }