Skip to content

Commit cdf9516

Browse files
thymikeeclaude
andcommitted
fix(record): read every validator run timeout as not playable
A validator run that hit its own 10 s bound threw, while one the deadline cut short read as not playable. Both are the same verdict: the file did not prove playable in time. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent afefe6b commit cdf9516

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

‎packages/capture-kit/src/recording/video.test.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ test('the validator run after a compile stays inside the caller deadline', async
182182
expect(withoutDeadline).toBe(10_000);
183183
});
184184

185-
test('a validator run the caller deadline cuts short reads as not playable', async () => {
185+
test('a validator run that times out reads as not playable, whatever bound stopped it', async () => {
186186
const mp4 = writeFixture('run-cut-short.mp4', Buffer.concat([ftyp, moov]));
187187
const host = { env: { AGENT_DEVICE_SWIFT_CACHE_DIR: '/cache/run-cut-short' }, cwd: directory };
188188
const timedOut = (timeoutMs: number) =>
@@ -192,10 +192,11 @@ test('a validator run the caller deadline cuts short reads as not playable', asy
192192
});
193193
try {
194194
await expect(isPlayableVideo(mp4, host, Deadline.fromTimeoutMs(5))).resolves.toBe(false);
195-
// Without a deadline, the validator's own bound is a failure to report, not a verdict.
196-
await expect(isPlayableVideo(mp4, host)).rejects.toMatchObject({
197-
details: { timeoutMs: 10_000 },
198-
});
195+
await expect(isPlayableVideo(mp4, host)).resolves.toBe(false);
196+
expect(vi.mocked(runCmd).mock.calls.map(([, , options]) => options?.timeoutMs)).toEqual([
197+
expect.any(Number),
198+
10_000,
199+
]);
199200
} finally {
200201
vi.mocked(runCmd).mockReset();
201202
vi.mocked(runCmd).mockResolvedValue({ exitCode: 0, stdout: '', stderr: '' });

‎packages/capture-kit/src/recording/video.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ export async function waitForStableFile(
8787

8888
/**
8989
* Whether the file is a playable video. With a `deadline`, a cold validator compile runs until the
90-
* deadline instead of its own fixed bound, and a validator run the deadline cuts short or leaves no
91-
* time for reads as not playable, like a poll in `waitForPlayableVideo` that runs out of time. A WebM
90+
* deadline instead of its own fixed bound. A validator run that times out, or that the deadline
91+
* leaves no time for, reads as not playable, like a poll in `waitForPlayableVideo` that runs out of
92+
* time. A WebM
9293
* verdict reads only the file's structure, with no validator, so the deadline does not apply to it.
9394
*/
9495
export async function isPlayableVideo(
@@ -118,8 +119,7 @@ export async function isPlayableVideo(
118119
timeoutMs: runTimeoutMs,
119120
env: buildSwiftToolEnv(host.env),
120121
}).catch((error: unknown) => {
121-
// The deadline, not the validator's own bound, cut this run short.
122-
if (runTimeoutMs < VALIDATOR_RUN_TIMEOUT_MS && isCommandTimeoutError(error)) return undefined;
122+
if (isCommandTimeoutError(error)) return undefined;
123123
throw error;
124124
});
125125
if (!result) return false;

0 commit comments

Comments
 (0)