Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use node.js timers explicitly to support Electron client-side #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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