-
Notifications
You must be signed in to change notification settings - Fork 59
Description
The promise returned by rtviClient.connect() never resolves, even when the connection is successfully established. This makes it impossible to reliably detect when a connection is ready using an await statement.
Steps to Reproduce
- Create an
RTVIClientinstance usingDailyTransport. - Call
await rtviClient.connect(). - Observe that the connection succeeds functionally:
- The
onTransportStateChangedcallback fires withstate='ready'. - Audio tracks start playing.
- Bot interaction works as expected.
- The
- Notice that the
connect()promise never resolves, and code execution halts at theawaitline.
Expected Behavior
The connect() promise should resolve once the transport state becomes 'ready' and the connection is fully established, allowing the await call to complete and subsequent code to execute.
Actual Behavior
The connection is successfully established and becomes fully functional. All relevant callbacks (onConnected, onTransportStateChanged, etc.) fire correctly. However, the await rtviClient.connect() call hangs indefinitely and never returns.
Code Example
import { RTVIClient } from "@pipecat-ai/client-js";
import { DailyTransport } from '@pipecat-ai/daily-transport';
const rtviClient = new RTVIClient({
transport: new DailyTransport(),
params: {
baseUrl: "[https://api.example.com](https://api.example.com)",
endpoints: { connect: "/connect" },
requestData: {
/* ... connection parameters ... */
},
},
callbacks: {
onConnected: () => {
console.log("Connected!"); // ✅ This fires
},
onTransportStateChanged: (state) => {
console.log("State:", state); // ✅ Fires with 'ready'
},
},
});console.log("About to call rtviClient.connect()...");
await rtviClient.connect(); // ❌ Hangs here forever
console.log("Returned from connect()!"); // ❌ This line is never reached
Observed Console Output:
About to call rtviClient.connect()...
State: ready
Connected!
// ... The connection works perfectly, but "Returned from connect()!" never appears.
Impact
This bug prevents standard asynchronous control flow and makes it difficult to:
- Reliably detect when the connection is complete.
- Use async/await for managing connection logic sequentially.
- Implement robust reconnection mechanisms that depend on the connect() method completing.
Workaround
The current workaround is to avoid awaiting the connect() promise and instead rely on the onTransportStateChanged callback to detect a successful connection.
const rtviClient = new RTVIClient({
// ... other config ...
callbacks: {
onTransportStateChanged: (state) => {
if (state === "ready") {
// Connection is ready, proceed with application logic here.
console.log("Connection is fully established.");
}
},
},
});// Call connect() without awaiting it.
rtviClient.connect();
Environment:
- Package: @pipecat-ai/client-js
- Transport: DailyTransport
- Browser: Chrome / Safari