Skip to content

Browser compatibility issue when trying to use AgentLiveClient #395

@dkozma

Description

@dkozma

What is the current behavior?

Browser throwing a Buffer is not defined error when trying to use the AgentLiveClient.

Steps to reproduce

I'm working off of the Voice Agent example, and it's throwing this error once binary data starts coming back from the WebSocket connection.

Expected behavior

What would you expect to happen when following the steps above?

I would expect this to not try to call a Node.js-only API in the browser.

Please tell us about your environment

We want to make sure the problem isn't specific to your operating system or programming language.

  • Operating System/Version: macOS 15.5
  • Language: TypeScript
  • Browser: Chrome

Other information

It looks like this function is trying to use Buffer.from(buffer) when processing incoming binary messages from the WebSocket connection, which is failing since the Buffer class is available in Node.js but not the browser. I don't want to have to polyfill Buffer in the browser for this to work.

In the browser, this should be able to use an ArrayBuffer directly, and not need to use Buffer.from. The function referenced above seems like it is created for the Node.js environment, since in the browser it should be able to pass through a Blob or ArrayBuffer to the emitter directly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions