Skip to content

Commit

Permalink
Use node.js timers explicitly to support Electron
Browse files Browse the repository at this point in the history
  • Loading branch information
dsamarin committed Aug 12, 2017
1 parent bdc467a commit dcef489
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/registry.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

var timers = require('timers')
var dnsEqual = require('dns-equal')
var flatten = require('array-flatten')
var Service = require('./service')
Expand Down Expand Up @@ -81,7 +82,7 @@ function probe (mdns, service, cb) {
var timer

mdns.on('response', onresponse)
setTimeout(send, Math.random() * 250)
timers.setTimeout(send, Math.random() * 250)

function send () {
// abort if the service have or is being stopped in the meantime
Expand All @@ -91,7 +92,7 @@ function probe (mdns, service, cb) {
// This function will optionally be called with an error object. We'll
// just silently ignore it and retry as we normally would
sent = true
timer = setTimeout(++retries < 3 ? send : done, 250)
timer = timers.setTimeout(++retries < 3 ? send : done, 250)
timer.unref()
})
}
Expand Down Expand Up @@ -146,7 +147,7 @@ function announce (server, service) {
}
delay = delay * REANNOUNCE_FACTOR
if (delay < REANNOUNCE_MAX_MS && !service._destroyed) {
setTimeout(broadcast, delay).unref()
timers.setTimeout(broadcast, delay).unref()
}
})
})()
Expand Down

0 comments on commit dcef489

Please sign in to comment.