Skip to content

Commit

Permalink
Merge branch 'main' into browser-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando authored Jul 3, 2023
2 parents cd43a49 + b544a47 commit 0b85aa8
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 28 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ test/typescript/*.js
test/typescript/*.map
# VS Code stuff
**/typings/**
**/.vscode/**

.npmrc
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"standard.enable": true,
"standard.autoFixOnSave": true,
"editor.defaultFormatter": "standard.vscode-standard"
}
53 changes: 49 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@


# [5.0.0-beta.2](https://github.com/mqttjs/MQTT.js/compare/v4.3.7...v5.0.0-beta.2) (2023-07-03)


### Bug Fixes

* browser tests not working ([#1628](https://github.com/mqttjs/MQTT.js/issues/1628)) ([8775fcd](https://github.com/mqttjs/MQTT.js/commit/8775fcdad952b39fa4b79dbe912ca42033be030a))
* setImmediate polyfill ([#1626](https://github.com/mqttjs/MQTT.js/issues/1626)) ([0ed0754](https://github.com/mqttjs/MQTT.js/commit/0ed0754b95b92df51ed49ae63058b31fdba1d415))


### Features

* option to disable `writeCache` and fix leak in subscriptions ([#1622](https://github.com/mqttjs/MQTT.js/issues/1622)) ([c8aa654](https://github.com/mqttjs/MQTT.js/commit/c8aa6540dbf68ffb0d88c287e2c862b28d3fb6e6)), closes [#1535](https://github.com/mqttjs/MQTT.js/issues/1535) [#1151](https://github.com/mqttjs/MQTT.js/issues/1151)



# [5.0.0-beta.1](https://github.com/mqttjs/MQTT.js/compare/v4.3.7...v5.0.0-beta.2) (2023-06-29)


### Bug Fixes

* `_storeProcessing` staying true after outStore got emptied ([#1492](https://github.com/mqttjs/MQTT.js/issues/1492)) ([f3f7be7](https://github.com/mqttjs/MQTT.js/commit/f3f7be76199115a622fde2590d44b1bb0cf57d41))
* consistency, used `this` instead of `that` ([#1618](https://github.com/mqttjs/MQTT.js/issues/1618)) ([800825b](https://github.com/mqttjs/MQTT.js/commit/800825bf619d83ef713a5b2fa1533bbf6ccac872))
* prevent store message on store when it's restored ([#1255](https://github.com/mqttjs/MQTT.js/issues/1255)) ([8d68c8c](https://github.com/mqttjs/MQTT.js/commit/8d68c8c3e38aede52741a06838933011a6fccc43))



# [5.0.0-beta.0](https://github.com/mqttjs/MQTT.js/compare/v4.3.7...v5.0.0-beta.2) (2023-06-27)


### Bug Fixes

* add missing export of UniqueMessageIdProvider and DefaultMessageIdProvider ([#1572](https://github.com/mqttjs/MQTT.js/issues/1572)) ([aa2e0ad](https://github.com/mqttjs/MQTT.js/commit/aa2e0ad49aadf333141f18cb85d2582abb8e19fc))
* IS_BROWSER check is now safer and more agnostic about the bundler ([#1571](https://github.com/mqttjs/MQTT.js/issues/1571)) ([b48b4b4](https://github.com/mqttjs/MQTT.js/commit/b48b4b4e79690c96033ea2df387c11f3bc26bf6a))
* **test:** `topicAliasMaximum` tests ([#1612](https://github.com/mqttjs/MQTT.js/issues/1612)) ([f1e5518](https://github.com/mqttjs/MQTT.js/commit/f1e5518150ea45067b87104abd9fed64ec13a48c))
* topicAliasMaximum under must be under Connect properties ([#1519](https://github.com/mqttjs/MQTT.js/issues/1519)) ([3b2e1cb](https://github.com/mqttjs/MQTT.js/commit/3b2e1cb7c4bf33ff66bcd1cc3091790a9635f19a))
* **types:** missing null declaration for error in subscription callback ([#1589](https://github.com/mqttjs/MQTT.js/issues/1589)) ([afc067b](https://github.com/mqttjs/MQTT.js/commit/afc067be2ca83990209b6176adec06f9a4c76a2c))
* **types:** topic alias controls and password ([#1509](https://github.com/mqttjs/MQTT.js/issues/1509)) ([85c9341](https://github.com/mqttjs/MQTT.js/commit/85c9341bba2676cfd069ec38a1a7cfda71647b68))


* chore!: drop support for node 12-14 (#1615) ([a2cbf61](https://github.com/mqttjs/MQTT.js/commit/a2cbf61c2a051a5ee69a50e00688e8ace79e7ef5)), closes [#1615](https://github.com/mqttjs/MQTT.js/issues/1615)


### BREAKING CHANGES

* Dropped support for NodeJS 12-14

# [5.0.0-beta.1](https://github.com/mqttjs/MQTT.js/compare/v5.0.0-beta.0...v5.0.0-beta.1) (2023-06-29)


Expand Down Expand Up @@ -739,7 +787,4 @@



# 0.1.0 (2012-01-17)



# 0.1.0 (2012-01-17)
40 changes: 20 additions & 20 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ const errors = {
162: 'Wildcard Subscriptions not supported'
}

function defaultId() {
function defaultId () {
return 'mqttjs_' + Math.random().toString(16).substr(2, 8)
}

function applyTopicAlias(client, packet) {
function applyTopicAlias (client, packet) {
if (client.options.protocolVersion === 5) {
if (packet.cmd === 'publish') {
let alias
Expand Down Expand Up @@ -144,7 +144,7 @@ function applyTopicAlias(client, packet) {
}
}

function removeTopicAliasAndRecoverTopicName(client, packet) {
function removeTopicAliasAndRecoverTopicName (client, packet) {
let alias
if (packet.properties) {
alias = packet.properties.topicAlias
Expand All @@ -169,7 +169,7 @@ function removeTopicAliasAndRecoverTopicName(client, packet) {
}
}

function sendPacket(client, packet, cb) {
function sendPacket (client, packet, cb) {
debug('sendPacket :: packet: %O', packet)
debug('sendPacket :: emitting `packetsend`')

Expand All @@ -187,7 +187,7 @@ function sendPacket(client, packet, cb) {
}
}

function flush(queue) {
function flush (queue) {
if (queue) {
debug('flush: queue exists? %b', !!(queue))
Object.keys(queue).forEach(function (messageId) {
Expand All @@ -201,7 +201,7 @@ function flush(queue) {
}
}

function flushVolatile(queue) {
function flushVolatile (queue) {
if (queue) {
debug('flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function')
Object.keys(queue).forEach(function (messageId) {
Expand All @@ -213,7 +213,7 @@ function flushVolatile(queue) {
}
}

function storeAndSend(client, packet, cb, cbStorePut) {
function storeAndSend (client, packet, cb, cbStorePut) {
debug('storeAndSend :: store packet with cmd %s to outgoingStore', packet.cmd)
let storePacket = packet
let err
Expand All @@ -227,7 +227,7 @@ function storeAndSend(client, packet, cb, cbStorePut) {
return cb && cb(err)
}
}
client.outgoingStore.put(storePacket, function storedPacket(err) {
client.outgoingStore.put(storePacket, function storedPacket (err) {
if (err) {
return cb && cb(err)
}
Expand All @@ -236,7 +236,7 @@ function storeAndSend(client, packet, cb, cbStorePut) {
})
}

function nop(error) {
function nop (error) {
debug('nop ::', error)
}

Expand All @@ -247,7 +247,7 @@ function nop(error) {
* @param {Object} [options] - connection options
* (see Connection#connect)
*/
function MqttClient(streamBuilder, options) {
function MqttClient (streamBuilder, options) {
let k
const that = this

Expand Down Expand Up @@ -339,7 +339,7 @@ function MqttClient(streamBuilder, options) {
this.on('connect', function () {
const queue = that.queue

function deliver() {
function deliver () {
const entry = queue.shift()
debug('deliver :: entry %o', entry)
let packet = null
Expand Down Expand Up @@ -427,7 +427,7 @@ MqttClient.prototype._setupStream = function () {
packets.push(packet)
})

function nextTickWork() {
function nextTickWork () {
if (packets.length) {
nextTick(work)
} else {
Expand All @@ -437,7 +437,7 @@ MqttClient.prototype._setupStream = function () {
}
}

function work() {
function work () {
debug('work :: getting next packet in queue')
const packet = packets.shift()

Expand All @@ -460,7 +460,7 @@ MqttClient.prototype._setupStream = function () {
work()
}

function streamErrorHandler(error) {
function streamErrorHandler (error) {
debug('streamErrorHandler :: error', error.message)
if (socketErrors.includes(error.code)) {
// handle error
Expand Down Expand Up @@ -989,7 +989,7 @@ MqttClient.prototype.end = function (force, opts, cb) {
debug('end :: cb? %s', !!cb)
cb = cb || nop

function closeStores() {
function closeStores () {
debug('end :: closeStores: closing incoming and outgoing stores')
that.disconnected = true
that.incomingStore.close(function (e1) {
Expand All @@ -1008,7 +1008,7 @@ MqttClient.prototype.end = function (force, opts, cb) {
}
}

function finish() {
function finish () {
// defer closesStores of an I/O cycle,
// just to make sure things are
// ok for websockets
Expand Down Expand Up @@ -1797,10 +1797,10 @@ MqttClient.prototype._onConnect = function (packet) {

this.connected = true

function startStreamProcess() {
function startStreamProcess () {
let outStore = that.outgoingStore.createStream()

function clearStoreProcessing() {
function clearStoreProcessing () {
that._storeProcessing = false
that._packetIdsDuringStoreProcessing = {}
}
Expand All @@ -1813,14 +1813,14 @@ MqttClient.prototype._onConnect = function (packet) {
that.emit('error', err)
})

function remove() {
function remove () {
outStore.destroy()
outStore = null
that._flushStoreProcessingQueue()
clearStoreProcessing()
}

function storeDeliver() {
function storeDeliver () {
// edge case, we wrapped this twice
if (!outStore) {
return
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mqtt",
"description": "A library for the MQTT protocol",
"version": "5.0.0-beta.1",
"version": "5.0.0-beta.2",
"contributors": [
"Adam Rudd <[email protected]>",
"Matteo Collina <[email protected]> (https://github.com/mcollina)",
Expand Down

0 comments on commit 0b85aa8

Please sign in to comment.