Skip to content

Commit 24a36bc

Browse files
authored
fix: ensure protocolVersion is a number in WebSocket options (#6013)
1 parent 1ac128e commit 24a36bc

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

packages/bruno-requests/src/ws/ws-client.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ class WsClient {
6767
};
6868

6969
if (protocolVersion) {
70-
wsOptions.protocolVersion = protocolVersion;
70+
// Force convert to number since `ws` doesn't do it for you
71+
const asNumber = Number(protocolVersion);
72+
if (!isNaN(asNumber)) {
73+
wsOptions.protocolVersion = asNumber;
74+
}
7175
}
7276

7377
const wsConnection = new ws.WebSocket(parsedUrl.fullUrl, protocols, wsOptions);

tests/websockets/fixtures/collection/ws-test-request-with-subproto.bru

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ ws {
1313
headers {
1414
Sec-WebSocket-Protocol: soap
1515
Sec-WebSocket-Protocol: mqtt
16+
Sec-WebSocket-Version: 13
1617
}
1718

1819
body:ws {

0 commit comments

Comments
 (0)