npm / ws
ws
What changed in ws 6 to 8, from its official release notes, upgrade guides and advisories. Also covers @types/ws. Sources checked 2026-11-28.
26 breaking3 security8 new APIs and options3 behavior and defaults6 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initws 835 changes
Breaking changes 17
The userinfo of the URL is now percent-decoded.
The server now rejects offers whose client_max_window_bits is smaller than configured clientMaxWindowBits.
The default value of maxFragments has been reduced.
Close reasons are passed to event listeners as Buffers instead of decoded strings.
The hook's protocols argument is now a Set instead of an Array.
Message listeners now receive data as a Buffer and take a boolean argument indicating whether the message is binary.
Support for Node.js versions earlier than 10.0.0 has been dropped.
The onclose, onerror, onmessage, and onopen properties are now null when their respective event handlers are unset.
The OpenEvent class has been removed.
The opening handshake is aborted if this header field value is empty or begins or ends with white space.
The server aborts the opening handshake when this header field value is invalid.
The constructor throws a SyntaxError when subprotocol names are invalid or duplicated.
Listeners registered through handler properties are now independent from listeners registered with addEventListener.
The method removes only listeners added with addEventListener, and removes only one at a time.
The constructor throws a SyntaxError if the connection URL contains a fragment identifier or uses a protocol other than ws:, wss:, or ws+unix:.
Calling close no longer closes existing connections; applications must close them manually if needed.
The callback receives an error if the server is already closed.
Security 3
Fixed a vulnerability where a malicious peer could force buffering of automatically sent Pong frames until memory was exhausted.
Fixed a vulnerability where tiny fragments and data chunks could crash a ws server or client due to OOM.
Prevents uninitialized memory disclosure when an unsupported TypedArray is passed as the reason argument.
New APIs and options 7
Introduced maxPendingAutoPong.
Introduced the protocols option.
Introduced maxBufferedChunks to configure buffering limits.
Introduced maxFragments to configure fragment limits.
The PerMessageDeflate class is now exported for developer use.
Utilities for the Sec-WebSocket-Extensions header are now exported.
Added the closeTimeout option.
Behavior and default changes 3
The default value of maxBufferedChunks has been reduced.
The package now uses an ES module wrapper.
The method is a noop when type is not close, error, message, or open.
Fixes and other changes 5
The constructor no longer mutates http: or https: url.URL objects.
The path of IPC URLs is no longer truncated at a colon.
Sender.frame() no longer returns empty chunks.
Invalid arguments no longer transition the state to WebSocket.CLOSING.
Handled a forthcoming breaking change in Node.js core.
ws 76 changes
Breaking changes 5
Support for Node.js 6 was dropped.
The constructor no longer supports url.Url instances.
When readyState is CONNECTING, an exception is thrown; when it is CLOSING or CLOSED, bufferedAmount increases by the data length in bytes, the callback receives an error if provided, and no exception is thrown if it is omitted.
When readyState is CONNECTING, an exception is thrown; when it is CLOSING or CLOSED, bufferedAmount increases by the data length in bytes, the callback receives an error if provided, and no exception is thrown if it is omitted.
When readyState is CONNECTING, an exception is thrown; when it is CLOSING or CLOSED, bufferedAmount increases by the data length in bytes, the callback receives an error if provided, and no exception is thrown if it is omitted.
Fixes and other changes 1
Fixed the fragment counter failing to reset, restoring the expected reset behavior.
ws 65 changes
Breaking changes 4
A shim throws an error when the package is used after being bundled for the browser.
Support for the
leveloption was dropped; usezlibDeflateOptionsinstead.Support for the
memLeveloption was dropped; usezlibDeflateOptionsinstead.Support for Node.js 4 was dropped.
New APIs and options 1
Added a client option for the maximum payload size, defaulting to 100 MiB.