Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send chunked WebSocket frames in a single write (prevent RSV2/3 errs) #150

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/http/sender.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,14 @@ class Sender {
*/
sendFrame(list, cb) {
if (list.length === 2) {
this._socket.write(list[0]);
this._socket.write(list[1], cb);
// The WebSocket frame is in two chunks. Merge the two byte arrays into a single byte array,
// and transmit in a single write (to prevent the receiving side from potentially processing
// a partial frame)
var mergedArray = new Uint8Array(list[0].length + list[1].length);
mergedArray.set(list[0]);
mergedArray.set(list[1], list[0].length);
this._socket.write(mergedArray, cb);

} else {
this._socket.write(list[0], cb);
}
Expand Down
Loading