ws
8.23.0 · 12 Nov 2026MIT428.4M / weekRepositorynpmAtom feed
2.3.1 is the newest release of 2.x.
In short
18 breaking7 new15 fixed
- Breaking
Dropped support for Node.js < 4.5.0.
- Breaking
The
newoperator is now required to create all instances as we moved to ES6 classes. - Breaking
Error messages have been simplified.
- Breaking
The
clientsproperty of theWebSocketServeris no longer anArraybut aSetand is only set if theclientTrackingoption is truthy (#806). - Breaking
The default HTTP status message is now used when handshake fails (41e7cae).
- Breaking
Removed support for the Hixie-76 version of the protocol (#871).
- Breaking
Removed ability to specify different paths for multiple
WebSocketServers when binding them to the same underlying HTTP/s server (#885). - Breaking
Removed
WebSocket.prototype.stream()and ability to pass a readable stream toWebSocket.prototype.send()(#875).
Security
2 advisories affect 2.0.0; 5.2.5 fixes them
- Highws: Memory exhaustion DoS from tiny fragments and data chunksGHSA-96hv-2xvq-fx4p · 15 Jun 2026Fixed in 5.2.5
- HighDenial of Service in wsGHSA-5v72-xg48-5rpm · 4 Jun 2019Fixed in 3.3.1
Release note
Breaking changes
- Breaking
Dropped support for Node.js < 4.5.0.
- Breaking
The
newoperator is now required to create all instances as we moved to ES6
classes. - Breaking
Error messages have been simplified.
- Breaking
The
clientsproperty of theWebSocketServeris no longer anArraybut aSetand is only set if theclientTrackingoption is truthy (#806). - Breaking
The default HTTP status message is now used when handshake fails (41e7cae).
- Breaking
Removed support for the Hixie-76 version of the protocol (#871).
- Breaking
Removed ability to specify different paths for multiple
WebSocketServers
when binding them to the same underlying HTTP/s server (#885). - Breaking
Removed
WebSocket.prototype.stream()and ability to pass a readable stream
toWebSocket.prototype.send()(#875). - Breaking
Removed callback argument from
handleProtocolshandler (#890). - Breaking
Removed
supportsproperty fromWebSocket(#918). - Breaking
Removed
WebSocket.createServer(),WebSocket.createConnection(), andWebSocket.connect()factory functions (#926). - Breaking
The second argument of
WebSocket.prototype.ping()andWebSocket.prototype.pong()is no longer an options object but a boolean
(#951). - Breaking
An error is emitted if
WebSocket.prototype.close()is called before the
connection is established (#956).
The following breaking changes only apply if you required the mentioned classes
directly.
- Breaking
Removed
Senderinheritance fromEventEmitter(#861). - Breaking
Removed
BufferPoolclass (73ab370). - Breaking
Made
extensionsa required argument for theReceiverconstructor (5f53194). - Breaking
receiver.onbinaryandreceiver.ontexthave been merged intoreceiver.onmessage(#939).
Features
Added ability to set TCP backlog for
WebSocketServer(#795).Added
checkServerIdentityoption toWebSocket(#701).Added a
thresholdoption for permessage-deflate to only compress messages
whose size is bigger thanthreshold(6b3904b).Added
shouldHandlemethod toWebSocketServerto see if a request should
be accepted or rejected. This method can be overridden by the user if a
custom logic is desired (6472425).Added
removeEventListenermethod toWebSocket(078e96a).Added
familyoption toWebSocket(#962).
Bug fixes
Fixed an issue that prevented permessage-deflate options from being correctly
handled (#744).All
errorevents are now emitted with a properErrorinstance (#789).Fixed an issue that could cause a stack overflow crash (#810).
Added 1012 and 1013 to the list of allowed close codes (b58f688).
Fixed an issue that prevented the connection from being closed when path
validation failed (#534).Fixed an issue where the
finoption ofWebSocket.prototype.send()was
unconditionally set totrue(ea50be7).Fixed an issue that prevented the total length of a fragmented message from
being correctly calculated (545635d).Fixed an issue where
zlib.flush()was called with a wrong flush level
(#733).The callback of
WebSocketServer.prototype.close()is now invoked when thecloseevent is emitted by the underlying HTTP/s server (#892).Fixed an issue that prevented the server from listening on IPv6 addresses
with default settings (dcdc652).Fixed an issue where the
connectionevent was emitted even if the client
closed the connection during the handshake process (04530ad).The masking key is now generated using
crypto.randomBytes()instead ofMath.random()(7253f06).Fixed an issue that, under particular circumstances, caused data to be
discarded (#945).Fixed an issue that prevented clients from being removed from the
clients
set (#955).WebSocket.prototype.close()now works as expected if called on the client
before the connection is established (#956).WebSocket.prototype.send()no longer mutates the options object (#968).The
bufferedAmountgetter now takes into account the data queued in the
sender (#971).
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.