diff --git a/lib/sender.js b/lib/sender.js index 5ea2986ee..c81ec66f6 100644 --- a/lib/sender.js +++ b/lib/sender.js @@ -80,7 +80,12 @@ class Sender { options.generateMask(mask); } else { if (randomPoolPointer === RANDOM_POOL_SIZE) { + /* istanbul ignore else */ if (randomPool === undefined) { + // + // This is lazily initialized because server-sent frames must not + // be masked so it may never be used. + // randomPool = Buffer.alloc(RANDOM_POOL_SIZE); } diff --git a/test/receiver.test.js b/test/receiver.test.js index 88a6326d1..1f9e75d3a 100644 --- a/test/receiver.test.js +++ b/test/receiver.test.js @@ -1127,7 +1127,7 @@ describe('Receiver', () => { receiver.on('ping', listener); receiver.on('pong', listener); - receiver.write(Buffer.from('8101318901328a0133810134', 'hex')); + receiver.write(Buffer.from('8101318901328a0133820134', 'hex')); }); it('does not swallow errors thrown from event handlers', (done) => { diff --git a/test/websocket.test.js b/test/websocket.test.js index 5570b1caf..aa53c3bc9 100644 --- a/test/websocket.test.js +++ b/test/websocket.test.js @@ -4423,6 +4423,7 @@ describe('WebSocket', () => { 'The socket was closed while data was being compressed' ); }); + ws.close(); }); } );