npm / mqtt
mqtt
What changed in mqtt 3 to 5, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
11 breaking4 security8 new APIs and options1 behavior and defaults14 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initmqtt 529 changes
Breaking changes 10
An acknowledgment that does not match the pending command for its message id is dropped and reported through error.
A getter provides access to negotiated keepalive now that CONNACK no longer mutates the options object.
A getter provides access to negotiated server properties now that CONNACK no longer mutates the options object.
The cap measures total wire size rather than Remaining Length, so it triggers on packets a few bytes smaller than before.
CONNACK properties no longer mutate the caller's options object; read negotiated values from the client getters instead.
Invalid or non-integer values outside 1..65535 are ignored; 65535 is enforced and advertised instead.
Protocol violations drop the connection, with reconnect remaining armed.
A refused CONNACK always closes the socket, including when reconnectOnConnackError is false.
Creating an MqttClient instance now requires the new keyword.
Support for Node.js 12–14 was dropped.
Security 4
Unsolicited or out-of-spec AUTH packets are rejected rather than crashing the process.
The advertised Receive Maximum is enforced for inbound QoS 2 messages, preventing an unbounded incoming store.
SUBACK reason-code counts are checked against subscriptions sent, preventing crashes or incorrect subscription reports.
Unsolicited MQTT 5 Topic Aliases are rejected rather than crashing the process; the unregistered-alias case reports reason code 0x82.
New APIs and options 5
PacketPump is newly exported from src/lib/shared.ts.
PendingCommand is newly exported from the entry point.
Topic validation functions are exported for external use.
Promises support was added.
An option to disable writeCache was added, alongside a fix for a leak in subscriptions.
Fixes and other changes 10
Reconnects instead of ending a client whose stream is already destroyed.
Schedules browser process.nextTick with queueMicrotask.
AUTH reason code 0 now ends the exchange successfully instead of producing an error with an empty reason string.
Duplicate CONNACK packets are rejected instead of rerunning connection setup mid-session.
An explicit servername (SNI) is no longer overwritten when connecting over TLS.
WebSocket connections now support relative URLs.
Added the missing export of DefaultMessageIdProvider.
Fixed a problem where the publish callback was invoked twice.
Fixed the placement of topicAliasMaximum under Connect properties.
Added the missing export of UniqueMessageIdProvider.
mqtt 43 changes
New APIs and options 2
A connection error handler was added.
TLS connections now support SNI.
Behavior and default changes 1
Client error handling changed; the notes do not specify further details.
mqtt 36 changes
Breaking changes 1
The connect event is emitted after processing of outgoingStore is completed.
New APIs and options 1
Adds support for MQTT 5.
Fixes and other changes 4
Processes a disconnect packet without fully destroying the connection.
Completed incoming QoS 2 messages are deleted.
Fixes publish being interrupted during stored packet processing.
Fixes MQTT 5 properties in subscribe.