mqtt 5.9.0 → 5.10.0

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
@@ -12625,7 +12625,7 @@ var mqtt = (() => {
12625
12625
  // package-json:../../package.json
12626
12626
  var require_package = __commonJS({
12627
12627
  "package-json:../../package.json"(exports5, module) {
12628
- module.exports = { version: "5.9.0" };
12628
+ module.exports = { version: "5.10.0" };
12629
12629
  }
12630
12630
  });
12631
12631
 
@@ -12684,6 +12684,7 @@ var mqtt = (() => {
12684
12684
  init_process2();
12685
12685
  Object.defineProperty(exports5, "__esModule", { value: true });
12686
12686
  exports5.ReasonCodes = void 0;
12687
+ var shared_1 = require_shared();
12687
12688
  exports5.ReasonCodes = {
12688
12689
  0: "",
12689
12690
  1: "Unacceptable protocol version",
@@ -12745,8 +12746,7 @@ var mqtt = (() => {
12745
12746
  case "puback": {
12746
12747
  const pubackRC = packet.reasonCode;
12747
12748
  if (pubackRC && pubackRC > 0 && pubackRC !== 16) {
12748
- err = new Error(`Publish error: ${exports5.ReasonCodes[pubackRC]}`);
12749
- err.code = pubackRC;
12749
+ err = new shared_1.ErrorWithReasonCode(`Publish error: ${exports5.ReasonCodes[pubackRC]}`, pubackRC);
12750
12750
  client["_removeOutgoingAndStoreMessage"](messageId, () => {
12751
12751
  cb(err, packet);
12752
12752
  });
@@ -12763,8 +12763,7 @@ var mqtt = (() => {
12763
12763
  };
12764
12764
  const pubrecRC = packet.reasonCode;
12765
12765
  if (pubrecRC && pubrecRC > 0 && pubrecRC !== 16) {
12766
- err = new Error(`Publish error: ${exports5.ReasonCodes[pubrecRC]}`);
12767
- err.code = pubrecRC;
12766
+ err = new shared_1.ErrorWithReasonCode(`Publish error: ${exports5.ReasonCodes[pubrecRC]}`, pubrecRC);
12768
12767
  client["_removeOutgoingAndStoreMessage"](messageId, () => {
12769
12768
  cb(err, packet);
12770
12769
  });
@@ -12799,7 +12798,7 @@ var mqtt = (() => {
12799
12798
  delete client.outgoing[messageId];
12800
12799
  client.messageIdProvider.deallocate(messageId);
12801
12800
  client["_invokeStoreProcessingQueue"]();
12802
- cb(null);
12801
+ cb(null, packet);
12803
12802
  break;
12804
12803
  }
12805
12804
  default:
@@ -18195,7 +18194,7 @@ var mqtt = (() => {
18195
18194
  subs[i6].qos = granted[i6];
18196
18195
  }
18197
18196
  }
18198
- callback(err, subs);
18197
+ callback(err, subs, packet2);
18199
18198
  }
18200
18199
  };
18201
18200
  this.log("subscribe :: call _sendPacket");
@@ -20732,7 +20731,9 @@ var mqtt = (() => {
20732
20731
  }
20733
20732
  this.isSocketOpen = false;
20734
20733
  this.proxy.on("data", (chunk) => {
20735
- this.push(chunk);
20734
+ if (!this.destroyed) {
20735
+ this.push(chunk);
20736
+ }
20736
20737
  });
20737
20738
  }
20738
20739
  _read(size) {
@@ -20961,7 +20962,9 @@ var mqtt = (() => {
20961
20962
  data = buffer_1.Buffer.from(data);
20962
20963
  else
20963
20964
  data = buffer_1.Buffer.from(data, "utf8");
20964
- proxy.push(data);
20965
+ if (proxy && !proxy.destroyed) {
20966
+ proxy.push(data);
20967
+ }
20965
20968
  }
20966
20969
  function socketWriteBrowser(chunk, enc, next) {
20967
20970
  if (socket.bufferedAmount > bufferSize) {