Skip to content

Commit ca124f3

Browse files
committed
waitForGeneration racing
1 parent 5f054d1 commit ca124f3

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

agents/src/voice/speech_handle.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,6 @@ export class SpeechHandle {
165165

166166
/** @internal */
167167
_authorizeGeneration(): void {
168-
if (this.interruptFut.done) {
169-
return;
170-
}
171168
const fut = new Future<void>();
172169
this.generations.push(fut);
173170
this.authorizedEvent.set();
@@ -194,7 +191,7 @@ export class SpeechHandle {
194191
if (!generation) {
195192
throw new Error(`Generation at index ${index} not found.`);
196193
}
197-
return generation.await;
194+
return Promise.race([generation.await, this.interruptFut.await]);
198195
}
199196

200197
/** @internal */

0 commit comments

Comments
 (0)