We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 98d4ece commit 374efb9Copy full SHA for 374efb9
genai/live/live-conversation-audio-with-audio.js
@@ -73,10 +73,17 @@ async function generateContent(
73
74
const responseQueue = [];
75
76
- async function waitMessage() {
+ async function waitMessage(timeoutMs = 60 * 1000) {
77
+ const startTime = Date.now();
78
+
79
while (responseQueue.length === 0) {
80
+ if (Date.now() - startTime > timeoutMs) {
81
+ console.warn('No messages received within timeout. Exiting...');
82
+ return null; // timeout occurred
83
+ }
84
await new Promise(resolve => setTimeout(resolve, 100));
85
}
86
87
return responseQueue.shift();
88
89
0 commit comments