From ad50e0f1cb120bd3bb0a9bdf944694785c9499dd Mon Sep 17 00:00:00 2001 From: Abdo Alsayed Date: Fri, 19 Apr 2024 21:42:03 +0300 Subject: [PATCH 1/2] fix: React Native App - TypeError: process.nextTick is not a function (it is undefined) This is to fix - process.nextTick is not a function (it is undefined) - error in react native apps. --- src/lib/connect/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/connect/index.ts b/src/lib/connect/index.ts index 27f0cb3a1..702fa066b 100644 --- a/src/lib/connect/index.ts +++ b/src/lib/connect/index.ts @@ -9,6 +9,11 @@ import MqttClient, { import IS_BROWSER from '../is-browser' import { StreamBuilder } from '../shared' +// Handling the process.nextTick is not a function error in react-native applications. +if (typeof process?.nextTick !== 'function') { + process.nextTick = setImmediate; +} + const debug = _debug('mqttjs') const protocols: Record = {} From 08fa9d08e799f726e3de2b41288e8af4f1c3a2ff Mon Sep 17 00:00:00 2001 From: abdelhameedalsayed Date: Mon, 22 Apr 2024 15:31:24 +0200 Subject: [PATCH 2/2] lint fixing --- package-lock.json | 21 +++++++-------------- src/lib/connect/index.ts | 2 +- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6637f2892..5647ab810 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18554,8 +18554,7 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-1.0.4.tgz", "integrity": "sha512-mLUsMkgP7K/cnFEw07kWqXGF5LKrOkD+lhCrKvPHXWDywAwuDUeDwWBpc69XK3pNX0uKiVt8g5z96PJ6z9xCFA==", - "dev": true, - "requires": {} + "dev": true }, "@octokit/plugin-rest-endpoint-methods": { "version": "7.2.3", @@ -20038,8 +20037,7 @@ "version": "7.5.9", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", - "dev": true, - "requires": {} + "dev": true } } }, @@ -20276,8 +20274,7 @@ "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true, - "requires": {} + "dev": true }, "add-stream": { "version": "1.0.0", @@ -22695,8 +22692,7 @@ "version": "9.0.0", "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.0.0.tgz", "integrity": "sha512-IcJsTkJae2S35pRsRAwoCE+925rJJStOdkKnLVgtE+tEpqU0EVVM7OqrwxqgptKdX29NUwC82I5pXsGFIgSevw==", - "dev": true, - "requires": {} + "dev": true }, "eslint-import-resolver-node": { "version": "0.3.9", @@ -27435,8 +27431,7 @@ "version": "8.13.0", "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", - "dev": true, - "requires": {} + "dev": true } } }, @@ -29235,8 +29230,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.1.tgz", "integrity": "sha512-lC/RGlPmwdrIBFTX59wwNzqh7aR2otPNPR/5brHZm/XKFYKsfqxihXUe9pU3JI+3vGkl+vyCoNNnPhJn3aLK1A==", - "dev": true, - "requires": {} + "dev": true }, "ts-node": { "version": "10.9.1", @@ -29975,8 +29969,7 @@ "ws": { "version": "8.14.2", "resolved": "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz", - "integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==", - "requires": {} + "integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==" }, "xdg-basedir": { "version": "5.1.0", diff --git a/src/lib/connect/index.ts b/src/lib/connect/index.ts index 702fa066b..8a3dee61c 100644 --- a/src/lib/connect/index.ts +++ b/src/lib/connect/index.ts @@ -11,7 +11,7 @@ import { StreamBuilder } from '../shared' // Handling the process.nextTick is not a function error in react-native applications. if (typeof process?.nextTick !== 'function') { - process.nextTick = setImmediate; + process.nextTick = setImmediate } const debug = _debug('mqttjs')