Skip to content

Commit 8889a59

Browse files
committed
fix: streams created by peers must initiate with an Ack message
1 parent 916cea6 commit 8889a59

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

src/WebSocketConnection.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,7 @@ class WebSocketConnection {
196196

197197
let stream = this.streamMap.get(streamId);
198198
if (stream == null) {
199-
const messageType = remainder.at(0);
200-
if (
201-
messageType === StreamMessageType.Close ||
202-
messageType === StreamMessageType.Error
203-
) {
199+
if (remainder.at(0) !== StreamMessageType.Ack) {
204200
return;
205201
}
206202
stream = await WebSocketStream.createWebSocketStream({

tests/WebSocketStream.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ jest.mock('@/WebSocketConnection', () => {
5353
let stream = instance.connectedConnection!.streamMap.get(streamId);
5454
if (stream == null) {
5555
const type = remainder.at(0);
56-
if (
57-
type === StreamMessageType.Close ||
58-
type === StreamMessageType.Error
59-
) {
56+
if (type !== StreamMessageType.Ack) {
6057
return;
6158
}
6259
stream = await WebSocketStream.createWebSocketStream({

0 commit comments

Comments
 (0)