Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handler: () => Boom.serverUnavailable('not ready')
internals.timeoutReply = function (request, timeout) {
const elapsed = Date.now() - request.info.received;
request._log(['request', 'server', 'timeout', 'error'], { timeout, elapsed });
request._reply(Boom.serverUnavailable());
};
pending.setTimeout(() => this._send(pending, Boom.serverUnavailable(), null, null, report), this.rule.generateTimeout);
}
internals.Sockets.prototype.auth = function (socket) {
if (!this._listener._settings.auth.index) {
return;
}
if (!socket.auth.credentials.user) {
return;
}
const user = socket.auth.credentials.user;
if (this._listener._settings.auth.maxConnectionsPerUser &&
this._byUser[user] &&
this._byUser[user].length >= this._listener._settings.auth.maxConnectionsPerUser) {
throw Boom.serverUnavailable('Too many connections for the authenticated user');
}
this._byUser[user] = this._byUser[user] || [];
this._byUser[user].push(socket);
};
if (this.settings.maxEventLoopDelay &&
load.eventLoopDelay > this.settings.maxEventLoopDelay) {
throw Boom.serverUnavailable('Server under heavy load (event loop)', load);
}
if (this.settings.maxHeapUsedBytes &&
load.heapUsed > this.settings.maxHeapUsedBytes) {
throw Boom.serverUnavailable('Server under heavy load (heap)', load);
}
if (this.settings.maxRssBytes &&
load.rss > this.settings.maxRssBytes) {
throw Boom.serverUnavailable('Server under heavy load (rss)', load);
}
};
const load = this.load;
if (elapsed > this.settings.sampleInterval) {
load.eventLoopDelay = Math.max(load.eventLoopDelay, elapsed - this.settings.sampleInterval);
}
if (this.settings.maxEventLoopDelay &&
load.eventLoopDelay > this.settings.maxEventLoopDelay) {
throw Boom.serverUnavailable('Server under heavy load (event loop)', load);
}
if (this.settings.maxHeapUsedBytes &&
load.heapUsed > this.settings.maxHeapUsedBytes) {
throw Boom.serverUnavailable('Server under heavy load (heap)', load);
}
if (this.settings.maxRssBytes &&
load.rss > this.settings.maxRssBytes) {
throw Boom.serverUnavailable('Server under heavy load (rss)', load);
}
};
return;
}
Hoek.assert(this._eventLoopTimer, 'Cannot check load when sampler is not started');
const elapsed = this._loadBench.elapsed();
const load = this.load;
if (elapsed > this.settings.sampleInterval) {
load.eventLoopDelay = Math.max(load.eventLoopDelay, elapsed - this.settings.sampleInterval);
}
if (this.settings.maxEventLoopDelay &&
load.eventLoopDelay > this.settings.maxEventLoopDelay) {
throw Boom.serverUnavailable('Server under heavy load (event loop)', load);
}
if (this.settings.maxHeapUsedBytes &&
load.heapUsed > this.settings.maxHeapUsedBytes) {
throw Boom.serverUnavailable('Server under heavy load (heap)', load);
}
if (this.settings.maxRssBytes &&
load.rss > this.settings.maxRssBytes) {
throw Boom.serverUnavailable('Server under heavy load (rss)', load);
}
};