Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (err ||
bytes !== 48) {
return team.attend(err || new Boom('Could not send entire message'));
}
});
try {
return await team.work;
}
finally {
clearTimeout(timeoutId);
socket.removeAllListeners();
socket.once('error', Hoek.ignore);
try {
socket.close();
}
catch (ignoreErr) { } // Ignore errors if the socket is already closed
}
};
}
resolve(result);
};
file.once('close', finalize);
file.once('error', finalize);
const onAbort = () => finalize(Boom.badRequest('Client connection aborted'));
req.once('aborted', onAbort);
internals.pipe(stream, counter);
internals.pipe(counter, file);
});
promise.catch(Hoek.ignore); // Prevent triggering node's PromiseRejectionHandledWarning
return promise;
};
Wreck.request('HEAD', url, {}, (err, res) => {
if (err ||
res.statusCode >= 400) {
return callback({});
}
Wreck.read(res, null, Hoek.ignore); // Flush out any payload
return callback(res.headers);
});
};
internals.Pack.prototype.start = function (callback) {
var self = this;
callback = callback || Hoek.ignore;
// Assert dependencies
for (var i = 0, il = this._core._dependencies.length; i < il; ++i) {
var dependency = this._core._dependencies[i];
for (var s = 0, sl = dependency.connections.length; s < sl; ++s) {
var server = dependency.connections[s];
for (var d = 0, dl = dependency.deps.length; d < dl; ++d) {
var dep = dependency.deps[d];
Hoek.assert(server._registrations[dep], 'Plugin', dependency.plugin, 'missing dependency', dep, 'in server:', server.info.uri);
}
}
}
// Start cache
const finish = Hoek.once((err, result) => {
clearTimeout(timeoutId);
socket.removeAllListeners();
socket.once('error', Hoek.ignore);
try {
socket.close();
}
catch (ignoreErr) { } // Ignore errors if the socket is already closed
return callback(err, result);
});
it('replies with a view', function (done) {
var server = new Hapi.Server();
server.register(Vision, Hoek.ignore);
server.connection();
server.views({
engines: { 'html': Handlebars },
path: __dirname + '/templates'
});
server.ext('onRequest', function (request, reply) {
return reply.view('test', { message: 'hola!' });
});
var handler = function (request, reply) {
return reply('ok');
};
server.start(function () {
for (var i = 0; i < 10; ++i) {
Http.get({
path: '/',
host: server.info.host,
port: server.info.port,
agent: httpAgent
}, Hoek.ignore);
Http.get({
path: '/foo',
host: server.info.host,
port: server.info.port,
agent: httpAgent
}, Hoek.ignore);
}
setTimeout(function () {
Items.parallel.execute({
requests: network.requests.bind(network),
concurrents: network.concurrents.bind(network),
response: network.responseTimes.bind(network),
sockets: network.sockets.bind(network, [httpAgent], [httpsAgent])
}, function (err, results) {
var port = server.info.port;
expect(err).to.not.exist();
expect(results.requests[port]).to.exist();
const finish = Hoek.once((err, result) => {
if (timeoutId) {
clearTimeout(timeoutId);
timeoutId = 0;
}
socket.removeAllListeners();
socket.once('error', Hoek.ignore);
socket.close();
return callback(err, result);
});
this.tables[table].changes = function (criteria, changesOptions) {
if (typeof changesOptions !== 'object') {
changesOptions = { handler: changesOptions };
}
const error = Table.error(Boom.internal('Simulated database error'), { table, action: method });
error.flags = Hoek.applyToDefaults({ willReconnect: true, disconnected: true }, options.flags || {});
process.nextTick(() => changesOptions.handler(error));
return { close: Hoek.ignore };
};
internals.Composer.prototype.start = function (callback) {
callback = callback || Hoek.ignore;
Async.forEachSeries(this._packs, function (pack, next) {
pack.start(next);
},
function (err) {
Hoek.assert(!err, 'Failed starting plugins:', err && err.message);
return callback();
});
};