Skip to content

Commit

Permalink
more comments, address nits
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyzha0 committed Oct 17, 2023
1 parent 550e438 commit 8182607
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions transport/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,21 @@ export class WebSocketTransport extends Transport {
// send outstanding
for (const id of this.sendQueue) {
const msg = this.sendBuffer.get(id);
if (msg) {
this.ws.send(this.codec.toStringBuf(msg));
if (!msg) {
return Promise.reject(
'tried to resend a message we received an ack for',
);
}

this.ws.send(this.codec.toStringBuf(msg));
}
}
}

send(msg: OpaqueTransportMessage): MessageId {
const id = msg.id;
if (this.destroyed) {
return id;
throw new Error('ws is destroyed, cant send');
}

this.sendBuffer.set(id, msg);
Expand Down

0 comments on commit 8182607

Please sign in to comment.