diff --git a/src/relay/pty-handler-output-drain-differential.test.ts b/src/relay/pty-handler-output-drain-differential.test.ts index 22ba265cd10..cbaee4bcb75 100644 --- a/src/relay/pty-handler-output-drain-differential.test.ts +++ b/src/relay/pty-handler-output-drain-differential.test.ts @@ -159,16 +159,20 @@ describe('relay PTY output drain — differential vs the pre-optimization snapsh async function spawnPtys(count: number): Promise { const ids: string[] = [] for (let i = 0; i < count; i++) { + let dataCallback!: (data: string) => void + let exitCallback!: (event: { exitCode: number }) => void mockPtySpawn.mockReturnValueOnce({ ...mockPtyInstance, onData: vi.fn((cb: (data: string) => void) => { - dataCallbacks.set(`pty-${i + 1}`, cb) + dataCallback = cb }), onExit: vi.fn((cb: (event: { exitCode: number }) => void) => { - exitCallbacks.set(`pty-${i + 1}`, cb) + exitCallback = cb }) }) const spawned = (await dispatcher.callRequest('pty.spawn', {})) as { id: string } + dataCallbacks.set(spawned.id, dataCallback) + exitCallbacks.set(spawned.id, exitCallback) ids.push(spawned.id) } return ids diff --git a/src/relay/subprocess.test.ts b/src/relay/subprocess.test.ts index 18d837bb4ef..1aea75a800d 100644 --- a/src/relay/subprocess.test.ts +++ b/src/relay/subprocess.test.ts @@ -204,7 +204,7 @@ describe('Subprocess: Relay entry point', () => { const repairedId = relay.send('pty.spawn', { cols: 80, rows: 24 }) const repaired = await relay.waitForResponse(repairedId) expect(repaired.error).toBeUndefined() - expect(repaired.result).toMatchObject({ id: 'pty-1' }) + expect(repaired.result).toMatchObject({ id: expect.any(String) }) }, 10_000) it('reloads node-pty after a late native binding failure without restarting', async () => { @@ -228,7 +228,7 @@ describe('Subprocess: Relay entry point', () => { const repairedId = relay.send('pty.spawn', { cols: 80, rows: 24 }) const repaired = await relay.waitForResponse(repairedId) expect(repaired.error).toBeUndefined() - expect(repaired.result).toMatchObject({ id: 'pty-2' }) + expect(repaired.result).toMatchObject({ id: expect.any(String) }) }, 10_000) it('responds to fs.stat over stdin/stdout', async () => {