diff --git a/client.js b/client.js index 6fc2179..fabbf63 100644 --- a/client.js +++ b/client.js @@ -3,6 +3,7 @@ const EventEmitter = require('events') const once = require('once') const parallel = require('run-parallel') const Peer = require('simple-peer') +const queueMicrotask = require('queue-microtask') const common = require('./lib/common') const HTTPTracker = require('./lib/client/http-tracker') // empty object in browser @@ -76,7 +77,7 @@ class Client extends EventEmitter { const webrtcSupport = this._wrtc !== false && (!!this._wrtc || Peer.WEBRTC_SUPPORT) const nextTickWarn = err => { - process.nextTick(() => { + queueMicrotask(() => { this.emit('warning', err) }) } diff --git a/package.json b/package.json index 960fac5..a75fe95 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "lru": "^3.1.0", "minimist": "^1.2.5", "once": "^1.4.0", + "queue-microtask": "^1.2.2", "random-iterate": "^1.0.1", "randombytes": "^2.1.0", "run-parallel": "^1.1.9",