Use queueMicrotask on client

This commit is contained in:
Feross Aboukhadijeh 2021-02-09 21:38:01 -08:00
parent 0c4911eaea
commit d8bb9c53f7
2 changed files with 3 additions and 1 deletions

View File

@ -3,6 +3,7 @@ const EventEmitter = require('events')
const once = require('once') const once = require('once')
const parallel = require('run-parallel') const parallel = require('run-parallel')
const Peer = require('simple-peer') const Peer = require('simple-peer')
const queueMicrotask = require('queue-microtask')
const common = require('./lib/common') const common = require('./lib/common')
const HTTPTracker = require('./lib/client/http-tracker') // empty object in browser 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 webrtcSupport = this._wrtc !== false && (!!this._wrtc || Peer.WEBRTC_SUPPORT)
const nextTickWarn = err => { const nextTickWarn = err => {
process.nextTick(() => { queueMicrotask(() => {
this.emit('warning', err) this.emit('warning', err)
}) })
} }

View File

@ -34,6 +34,7 @@
"lru": "^3.1.0", "lru": "^3.1.0",
"minimist": "^1.2.5", "minimist": "^1.2.5",
"once": "^1.4.0", "once": "^1.4.0",
"queue-microtask": "^1.2.2",
"random-iterate": "^1.0.1", "random-iterate": "^1.0.1",
"randombytes": "^2.1.0", "randombytes": "^2.1.0",
"run-parallel": "^1.1.9", "run-parallel": "^1.1.9",