mqtt 4.3.6 → 4.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mqtt.js CHANGED
@@ -1585,7 +1585,18 @@ MqttClient.prototype._handleAck = function (packet) {
1585
1585
  const that = this
1586
1586
  let err
1587
1587
 
1588
- if (!cb || cb === nop) {
1588
+ // Checking `!cb` happens to work, but it's not technically "correct".
1589
+ //
1590
+ // Why? This code assumes that "no callback" is the same as that "we're not
1591
+ // waiting for responses" (puback, pubrec, pubcomp, suback, or unsuback).
1592
+ //
1593
+ // It would be better to check `if (!this.outgoing[messageId])` here, but
1594
+ // there's no reason to change it and risk (another) regression.
1595
+ //
1596
+ // The only reason this code works is becaues code in MqttClient.publish,
1597
+ // MqttClinet.subscribe, and MqttClient.unsubscribe ensures that we will
1598
+ // have a callback even if the user doesn't pass one in.)
1599
+ if (!cb) {
1589
1600
  debug('_handleAck :: Server sent an ack in error. Ignoring.')
1590
1601
  // Server sent an ack in error, ignore it.
1591
1602
  return