fix(companion): validate event wait timeout options
This commit is contained in:
@@ -359,6 +359,9 @@ describe('CompanionRuntimeClient', () => {
|
||||
expect(() => client.waitForEvent(123 as unknown as string)).toThrow(
|
||||
'eventName must be a non-empty string',
|
||||
);
|
||||
expect(() => client.waitForEvent('agent.stream', { timeoutMs: 0 })).toThrow(
|
||||
'timeoutMs must be a positive number',
|
||||
);
|
||||
});
|
||||
|
||||
it('waitForEvent supports AbortSignal cancellation', async () => {
|
||||
@@ -600,6 +603,9 @@ describe('CompanionRuntimeClient', () => {
|
||||
expect(() => client.waitForAnyEvent(['agent.stream', 123 as unknown as string])).toThrow(
|
||||
'eventNames must not contain empty values',
|
||||
);
|
||||
expect(() => client.waitForAnyEvent(['agent.stream'], { timeoutMs: 0 })).toThrow(
|
||||
'timeoutMs must be a positive number',
|
||||
);
|
||||
});
|
||||
|
||||
it('tracks pendingRequestCount for in-flight RPCs', async () => {
|
||||
|
||||
@@ -477,6 +477,9 @@ export class CompanionRuntimeClient {
|
||||
throw new Error('eventName must be a non-empty string');
|
||||
}
|
||||
const timeoutMs = options?.timeoutMs ?? this.requestTimeoutMs;
|
||||
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
||||
throw new Error('timeoutMs must be a positive number');
|
||||
}
|
||||
const predicate = options?.predicate;
|
||||
const signal = options?.signal;
|
||||
|
||||
@@ -550,6 +553,9 @@ export class CompanionRuntimeClient {
|
||||
}
|
||||
const eventNameSet = new Set(eventNames);
|
||||
const timeoutMs = options?.timeoutMs ?? this.requestTimeoutMs;
|
||||
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
||||
throw new Error('timeoutMs must be a positive number');
|
||||
}
|
||||
const predicate = options?.predicate;
|
||||
const signal = options?.signal;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user