Skip to content

Commit

Permalink
Use WebSocket.binaryType "arraybuffer" for Bun runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Swimburger committed Jan 24, 2025
1 parent bd38032 commit f84dd97
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cartesia/cartesia-js",
"version": "2.1.3",
"version": "2.1.4",
"private": false,
"repository": "https://github.com/cartesia-ai/cartesia-js",
"main": "./index.js",
Expand Down
7 changes: 7 additions & 0 deletions src/wrapper/Websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import { Tts } from "../api/resources/tts/client/Client";
import Source from "./source";
import qs from "qs";
import { RUNTIME } from "../core";

export default class Websocket {
socket?: ReconnectingWebSocket;
Expand Down Expand Up @@ -194,6 +195,12 @@ export default class Websocket {
undefined,
options
);

// bun doesn't support the default `blob` binaryType
if (RUNTIME.type === "bun") {
this.socket.binaryType = "arraybuffer";
}

this.socket!.reconnect();

this.socket!.onopen = () => {
Expand Down

0 comments on commit f84dd97

Please sign in to comment.