summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2024-01-02 10:30:09 +0530
committerGitHub <noreply@github.com>2024-01-02 10:30:09 +0530
commit8e4feacd258b2fc019f2b9612133231fa8be14c0 (patch)
tree717333e65d6448d7e0c6bccf6ce89229d663cb76
parent642c4a44a56ed02c2bf795bf04d7aebbc847e150 (diff)
fix(ext/http): use arraybuffer binaryType for server websocket (#21741)
Ref https://github.com/denoland/deno/issues/15340#issuecomment-1872353134
-rw-r--r--cli/tests/unit/websocket_test.ts1
-rw-r--r--ext/websocket/01_websocket.js6
2 files changed, 6 insertions, 1 deletions
diff --git a/cli/tests/unit/websocket_test.ts b/cli/tests/unit/websocket_test.ts
index 7f9f26a35..47d056492 100644
--- a/cli/tests/unit/websocket_test.ts
+++ b/cli/tests/unit/websocket_test.ts
@@ -381,6 +381,7 @@ Deno.test(
assert(typeof socket.url == "string");
assert(socket.readyState == WebSocket.OPEN);
assert(socket.protocol == "");
+ assert(socket.binaryType == "arraybuffer");
socket.close();
};
socket.onclose = () => ac.abort();
diff --git a/ext/websocket/01_websocket.js b/ext/websocket/01_websocket.js
index f28e3ef1b..57689d1ae 100644
--- a/ext/websocket/01_websocket.js
+++ b/ext/websocket/01_websocket.js
@@ -590,7 +590,11 @@ function createWebSocketBranded() {
socket[_extensions] = "";
socket[_protocol] = "";
socket[_url] = "";
- socket[_binaryType] = "blob";
+ // We use ArrayBuffer for server websockets for backwards compatibility
+ // and performance reasons.
+ //
+ // https://github.com/denoland/deno/issues/15340#issuecomment-1872353134
+ socket[_binaryType] = "arraybuffer";
socket[_idleTimeoutDuration] = 0;
socket[_idleTimeoutTimeout] = undefined;
return socket;