// Retry function. Will wait up to the wait interval, with some // random noise if one is provided. Otherwise, will go immediately. function retry() { if (!self.waitInterval) { setImmediate(function() { self._read(size); }); } else { setTimeout(function() { self._read(size); }, self.waitInterval * Math.random()).unref(); } }
setInterval(function() { try { self.poll(); } catch (e) { // We can probably ignore errors here as far as broadcasting. // Disconnection issues will get handled below } }, interval).unref()
}, 10000).unref();
}, 1000).unref(); }) .on('end', function() {
/** * * * @param {any} signal * @param {any} timeout * @memberof GracefulShutdown */ terminateAfterTimeout(signal, timeout) { setTimeout(() => { this.logger.error({ signal, timeout }, 'terminate process after timeout') this.process.exit(1) }, timeout).unref() }
applicationUnderMonitoring.getMainPackageJson((err, packageJson) => { if (err) { return logger.warn('Failed to determine main package json. Reason: ', err.message, err.stack); } else if (!packageJson && attempts < MAX_ATTEMPTS) { setTimeout(exports.activate, DELAY).unref(); return; } else if (!packageJson) { // final attempt failed, ignore silently return; } exports.currentPayload = packageJson.description; });
_watchFailure(watch) { if (this._xrun.stopOnError !== "full") return undefined; return setTimeout(() => { if (watch.finish) return 0; if (this._xrun.failed) { this._xrun.emit("fail-cancel", watch); return watch.cancel(); } return this._watchFailure(watch); }, 50).unref(); }
setImmediate(function pollSource( ) { var chunk = source.read(100000) if (chunk && chunk.length > 0) { if (typeof chunk !== 'string') chunk = decoder.write(chunk) data = self.onData(data, chunk, output) setImmediate(pollSource) } else if (!self._closed) { var poller = setTimeout(pollSource, 2) if (poller.unref) poller.unref() } })
function _setup(options) { options = options || {}; logger = options.logger || logger; if (cluster.isMaster) { if (options.mockData) { options.mockData.forEach(function(mock) { // key, value, ttl cache[mock.key] = new CacheEntry(mock); }); } if (options.purgeInterval) { purgeIntervalObj = setInterval(function() { _purgeCache(); }, options.purgeInterval).unref(); } } }
setImmediate(function pollResponses( ) { var chunk = readable.read(100000) if (chunk && chunk.length > 0) { if (typeof chunk !== 'string') chunk = decoder.write(chunk) self.chunks.push(chunk) self._deliverResponses(function() { setImmediate(pollResponses) }) } else if (this._connected) { var poller = setTimeout(pollResponses, 2) if (poller.unref) poller.unref() } })
// renew every 90-ish minutes (random for staggering) // the weak setTimeout (unref) means that when run as a CLI process this // will still finish as expected, and not wait on the timeout (function renew() { setTimeout(function() { greenlock.renew({}); renew(); }, Math.PI * 30 * 60 * 1000).unref(); })();
applicationUnderMonitoring.getMainPackageJsonPath((err, packageJsonPath) => { if (err) { return logger.info( 'Failed to determine main package.json for analysis of direct dependencies. Reason: %s %s ', err.message, err.stack ); } else if (!packageJsonPath && attempts < MAX_ATTEMPTS) { setTimeout(exports.activate, DELAY).unref(); return; } else if (!packageJsonPath) { // final attempt failed, ignore silently return; } addDirectDependenciesFromMainPackageJson(packageJsonPath); });
applicationUnderMonitoring.getMainPackageJson((err, packageJson) => { if (err) { return logger.warn('Failed to determine main package json. Reason: ', err.message, err.stack); } else if (!packageJson && attempts < MAX_ATTEMPTS) { setTimeout(exports.activate, DELAY).unref(); return; } else if (!packageJson) { // final attempt failed, ignore silently return; } if (packageJson.keywords) { exports.currentPayload = packageJson.keywords; } });
applicationUnderMonitoring.getMainPackageJson((err, packageJson) => { if (err) { return logger.warn('Failed to determine main package json. Reason: ', err.message, err.stack); } else if (!packageJson && attempts < MAX_ATTEMPTS) { setTimeout(exports.activate, DELAY).unref(); return; } else if (!packageJson) { // final attempt failed, ignore silently return; } exports.currentPayload = packageJson.version; });
// Retry function. Will wait up to the wait interval, with some // random noise if one is provided. Otherwise, will go immediately. function retry() { if (!self.waitInterval) { setImmediate(function() { self._read(size); }); } else { setTimeout(function() { self._read(size); }, self.waitInterval * Math.random()).unref(); } }