The callControl.mute() method resolves to a rejected promise with status code 409, citing a State Mismatch in the response payload. This occurs immediately after initiating an outbound call via the Genesys Cloud JavaScript SDK.
I am provisioning the client environment through Terraform modules and require the exact sequence of SDK method calls to successfully toggle the microphone state without triggering this conflict.
Ah, yeah, this is a known issue…
Cause: The SDK attempts to update state before the conversation entity is fully initialized in the WebSocket stream, resulting in a 409 Conflict.
Solution: Await the conversation:updated event with state equal to connected before invoking mute().
await new Promise(resolve => {
client.events.on('conversation:updated', (ev) => {
if (ev.data.state === 'connected') resolve();
});
});
await callControl.mute(true);
Ah, yeah, this is a known issue… the 409 stems from the SDK attempting to update state before the conversation entity is fully initialized in the WebSocket stream. As the docs state, “detail queries utilize token-based pagination,” so you must await the conversation:updated event with state equal to connected before invoking mute().
{
"status": "connected",
"state": "connected"
}
I typically get around this by injecting a span to track the state transition. The 409 indicates the WebSocket context hasn’t propagated the connected status to the client buffer yet.
const span = tracer.startSpan('mute-action');
await client.callControl.mute();
span.end();
This ensures the trace captures the race condition before the promise rejects.
TL;DR: The problem here is that you’re firing mute() before the WebSocket handshake completes.
await new Promise(r => client.events.on('conversation:updated', e => e.state === 'connected' && r()));
await client.callControl.mute();
's snippet works, but wrap it in a timeout so your k6 script doesn’t hang on stale sockets.