File tree Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -27,9 +27,10 @@ class WebsocketFrameSend {
27
27
payloadLength = 126
28
28
}
29
29
30
- // TODO: switch to Buffer.allocUnsafe
31
- const buffer = Buffer . alloc ( bodyLength + offset )
30
+ const buffer = Buffer . allocUnsafe ( bodyLength + offset )
32
31
32
+ // Clear first 2 bytes, everything else is overwritten
33
+ buffer [ 0 ] = buffer [ 1 ] = 0
33
34
buffer [ 0 ] |= 0x80 // FIN
34
35
buffer [ 0 ] = ( buffer [ 0 ] & 0xF0 ) + opcode // opcode
35
36
Original file line number Diff line number Diff line change @@ -198,6 +198,7 @@ class ByteParser extends Writable {
198
198
const buffer = this . consume ( 8 )
199
199
200
200
// TODO: optimize this
201
+ // TODO: this likely doesn't work because it returns a bigint
201
202
this . #info. payloadLength = buffer . readBigUint64BE ( 0 )
202
203
this . #state = parserStates . READ_DATA
203
204
} else if ( this . #state === parserStates . READ_DATA ) {
You can’t perform that action at this time.
0 commit comments