Skip to content

Commit

Permalink
fix: streams created by peers must initiate with an Ack message
Browse files Browse the repository at this point in the history
  • Loading branch information
amydevs committed Sep 8, 2023
1 parent 916cea6 commit 8889a59
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
6 changes: 1 addition & 5 deletions src/WebSocketConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,7 @@ class WebSocketConnection {

let stream = this.streamMap.get(streamId);
if (stream == null) {
const messageType = remainder.at(0);
if (
messageType === StreamMessageType.Close ||
messageType === StreamMessageType.Error
) {
if (remainder.at(0) !== StreamMessageType.Ack) {
return;
}
stream = await WebSocketStream.createWebSocketStream({
Expand Down
5 changes: 1 addition & 4 deletions tests/WebSocketStream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ jest.mock('@/WebSocketConnection', () => {
let stream = instance.connectedConnection!.streamMap.get(streamId);
if (stream == null) {
const type = remainder.at(0);
if (
type === StreamMessageType.Close ||
type === StreamMessageType.Error
) {
if (type !== StreamMessageType.Ack) {
return;
}
stream = await WebSocketStream.createWebSocketStream({
Expand Down

0 comments on commit 8889a59

Please sign in to comment.