test: add trailing commas in async-hooks tests (#45549)

PR-URL: https://github.com/nodejs/node/pull/45549
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
This commit is contained in:
Antoine du Hamel 2022-11-21 12:43:47 -05:00 committed by GitHub
parent 4f20c882ec
commit cf46746b8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 78 additions and 79 deletions

View File

@ -72,7 +72,6 @@ globals:
overrides: overrides:
- files: - files:
- async-hooks/*.js
- es-module/*.js - es-module/*.js
- es-module/*.mjs - es-module/*.mjs
- internet/*.js - internet/*.js

View File

@ -21,7 +21,7 @@ exports.checkInvocations = function checkInvocations(activity, hooks, stage) {
assert.ok(activity != null, assert.ok(activity != null,
`${stageInfo} Trying to check invocation for an activity, ` + `${stageInfo} Trying to check invocation for an activity, ` +
'but it was empty/undefined.' 'but it was empty/undefined.',
); );
// Check that actual invocations for all hooks match the expected invocations // Check that actual invocations for all hooks match the expected invocations

View File

@ -27,7 +27,7 @@ class ActivityCollector {
ondestroy, ondestroy,
onpromiseResolve, onpromiseResolve,
logid = null, logid = null,
logtype = null logtype = null,
} = {}) { } = {}) {
this._start = start; this._start = start;
this._allowNoInit = allowNoInit; this._allowNoInit = allowNoInit;
@ -49,7 +49,7 @@ class ActivityCollector {
before: this._before.bind(this), before: this._before.bind(this),
after: this._after.bind(this), after: this._after.bind(this),
destroy: this._destroy.bind(this), destroy: this._destroy.bind(this),
promiseResolve: this._promiseResolve.bind(this) promiseResolve: this._promiseResolve.bind(this),
}); });
} }
@ -181,7 +181,7 @@ class ActivityCollector {
// In some cases (e.g. Timeout) the handle is a function, thus the usual // In some cases (e.g. Timeout) the handle is a function, thus the usual
// `typeof handle === 'object' && handle !== null` check can't be used. // `typeof handle === 'object' && handle !== null` check can't be used.
handleIsObject: handle instanceof Object, handleIsObject: handle instanceof Object,
handle handle,
}; };
this._stamp(activity, 'init'); this._stamp(activity, 'init');
this._activities.set(uid, activity); this._activities.set(uid, activity);
@ -233,7 +233,7 @@ exports = module.exports = function initHooks({
onpromiseResolve, onpromiseResolve,
allowNoInit, allowNoInit,
logid, logid,
logtype logtype,
} = {}) { } = {}) {
return new ActivityCollector(process.hrtime(), { return new ActivityCollector(process.hrtime(), {
oninit, oninit,
@ -243,6 +243,6 @@ exports = module.exports = function initHooks({
onpromiseResolve, onpromiseResolve,
allowNoInit, allowNoInit,
logid, logid,
logtype logtype,
}); });
}; };

View File

@ -22,7 +22,7 @@ const hooks = initHooks({
onbefore, onbefore,
onafter, onafter,
ondestroy: null, // Intentionally not tested, since it will be removed soon ondestroy: null, // Intentionally not tested, since it will be removed soon
onpromiseResolve onpromiseResolve,
}); });
hooks.enable(); hooks.enable();

View File

@ -12,7 +12,7 @@ const hooked = {};
createHook({ createHook({
init(asyncId, type, triggerAsyncId, resource) { init(asyncId, type, triggerAsyncId, resource) {
hooked[asyncId] = resource; hooked[asyncId] = resource;
} },
}).enable(); }).enable();
const server = http.createServer((req, res) => { const server = http.createServer((req, res) => {

View File

@ -13,7 +13,7 @@ const hooked = {};
createHook({ createHook({
init(asyncId, type, triggerAsyncId, resource) { init(asyncId, type, triggerAsyncId, resource) {
hooked[asyncId] = resource; hooked[asyncId] = resource;
} },
}).enable(); }).enable();
const server = http.createServer((req, res) => { const server = http.createServer((req, res) => {

View File

@ -6,7 +6,7 @@ const { readFile } = require('fs');
const { const {
createHook, createHook,
executionAsyncResource, executionAsyncResource,
AsyncResource AsyncResource,
} = require('async_hooks'); } = require('async_hooks');
// Ignore any asyncIds created before our hook is active. // Ignore any asyncIds created before our hook is active.
@ -32,7 +32,7 @@ createHook({
if (asyncId >= firstSeenAsyncId) { if (asyncId >= firstSeenAsyncId) {
afterHook(asyncId); afterHook(asyncId);
} }
} },
}).enable(); }).enable();
const beforeHook = common.mustCallAtLeast( const beforeHook = common.mustCallAtLeast(

View File

@ -7,7 +7,7 @@ const http = require('http');
const asyncLocalStorage = new AsyncLocalStorage(); const asyncLocalStorage = new AsyncLocalStorage();
const agent = new http.Agent({ const agent = new http.Agent({
maxSockets: 1 maxSockets: 1,
}); });
const N = 3; const N = 3;

View File

@ -18,7 +18,7 @@ function onPropagate(type, store) {
} }
const als = new AsyncLocalStorage({ const als = new AsyncLocalStorage({
onPropagate: common.mustCall(onPropagate, 2) onPropagate: common.mustCall(onPropagate, 2),
}); });
const myStore = {}; const myStore = {};
@ -40,11 +40,11 @@ als.run(myStore, common.mustCall(() => {
assert.throws(() => new AsyncLocalStorage(15), { assert.throws(() => new AsyncLocalStorage(15), {
message: 'The "options" argument must be of type object. Received type number (15)', message: 'The "options" argument must be of type object. Received type number (15)',
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError' name: 'TypeError',
}); });
assert.throws(() => new AsyncLocalStorage({ onPropagate: 'bar' }), { assert.throws(() => new AsyncLocalStorage({ onPropagate: 'bar' }), {
message: 'The "options.onPropagate" property must be of type function. Received type string (\'bar\')', message: 'The "options.onPropagate" property must be of type function. Received type string (\'bar\')',
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError' name: 'TypeError',
}); });

View File

@ -17,7 +17,7 @@ const then = common.mustCall((cb) => {
function thenable() { function thenable() {
return { return {
then then,
}; };
} }

View File

@ -14,7 +14,7 @@ const { AsyncLocalStorage } = require('async_hooks');
const options = { const options = {
cert: fixtures.readKey('rsa_cert.crt'), cert: fixtures.readKey('rsa_cert.crt'),
key: fixtures.readKey('rsa_private.pem'), key: fixtures.readKey('rsa_private.pem'),
rejectUnauthorized: false rejectUnauthorized: false,
}; };
tls tls

View File

@ -9,14 +9,14 @@ const arg = process.argv[2];
switch (arg) { switch (arg) {
case 'test_init_callback': case 'test_init_callback':
initHooks({ initHooks({
oninit: common.mustCall(() => { throw new Error(arg); }) oninit: common.mustCall(() => { throw new Error(arg); }),
}).enable(); }).enable();
new async_hooks.AsyncResource(`${arg}_type`); new async_hooks.AsyncResource(`${arg}_type`);
return; return;
case 'test_callback': { case 'test_callback': {
initHooks({ initHooks({
onbefore: common.mustCall(() => { throw new Error(arg); }) onbefore: common.mustCall(() => { throw new Error(arg); }),
}).enable(); }).enable();
const resource = new async_hooks.AsyncResource(`${arg}_type`); const resource = new async_hooks.AsyncResource(`${arg}_type`);
resource.runInAsyncScope(() => {}); resource.runInAsyncScope(() => {});
@ -25,7 +25,7 @@ switch (arg) {
case 'test_callback_abort': case 'test_callback_abort':
initHooks({ initHooks({
oninit: common.mustCall(() => { throw new Error(arg); }) oninit: common.mustCall(() => { throw new Error(arg); }),
}).enable(); }).enable();
new async_hooks.AsyncResource(`${arg}_type`); new async_hooks.AsyncResource(`${arg}_type`);
return; return;

View File

@ -23,7 +23,7 @@ createHook({
if (activeId === id) { if (activeId === id) {
activeId = -1; activeId = -1;
} }
} },
}).enable(); }).enable();
function testNextTick() { function testNextTick() {
@ -33,7 +33,7 @@ function testNextTick() {
res.emitDestroy(); res.emitDestroy();
// nextTick has higher prio than emit destroy // nextTick has higher prio than emit destroy
process.nextTick(common.mustCall(() => process.nextTick(common.mustCall(() =>
assert.strictEqual(activeId, res.asyncId())) assert.strictEqual(activeId, res.asyncId())),
); );
} }
@ -44,7 +44,7 @@ function testQueueMicrotask() {
res.emitDestroy(); res.emitDestroy();
// queueMicrotask has higher prio than emit destroy // queueMicrotask has higher prio than emit destroy
queueMicrotask(common.mustCall(() => queueMicrotask(common.mustCall(() =>
assert.strictEqual(activeId, res.asyncId())) assert.strictEqual(activeId, res.asyncId())),
); );
} }
@ -54,7 +54,7 @@ function testImmediate() {
assert.strictEqual(activeId, res.asyncId()); assert.strictEqual(activeId, res.asyncId());
res.emitDestroy(); res.emitDestroy();
setImmediate(common.mustCall(() => setImmediate(common.mustCall(() =>
assert.strictEqual(activeId, -1)) assert.strictEqual(activeId, -1)),
); );
} }
@ -65,7 +65,7 @@ function testPromise() {
res.emitDestroy(); res.emitDestroy();
// Promise has higher prio than emit destroy // Promise has higher prio than emit destroy
Promise.resolve().then(common.mustCall(() => Promise.resolve().then(common.mustCall(() =>
assert.strictEqual(activeId, res.asyncId())) assert.strictEqual(activeId, res.asyncId())),
); );
} }

View File

@ -13,11 +13,11 @@ async_hooks.createHook({
nestedCall = true; nestedCall = true;
fs.access(__filename, common.mustCall()); fs.access(__filename, common.mustCall());
} }
}, 2) }, 2),
}).enable(); }).enable();
const nestedHook = async_hooks.createHook({ const nestedHook = async_hooks.createHook({
init: common.mustCall(2) init: common.mustCall(2),
}).enable(); }).enable();
fs.access(__filename, common.mustCall()); fs.access(__filename, common.mustCall());

View File

@ -20,7 +20,7 @@ if (process.argv[2] === 'child') {
[null, undefined, 1, Date, {}, []].forEach((i) => { [null, undefined, 1, Date, {}, []].forEach((i) => {
assert.throws(() => new Foo(i), { assert.throws(() => new Foo(i), {
code: 'ERR_INVALID_ARG_TYPE', code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError' name: 'TypeError',
}); });
}); });

View File

@ -26,7 +26,7 @@ assert.throws(() => {
assert.strictEqual( assert.strictEqual(
new AsyncResource('default_trigger_id').triggerAsyncId(), new AsyncResource('default_trigger_id').triggerAsyncId(),
async_hooks.executionAsyncId() async_hooks.executionAsyncId(),
); );
// Create first custom event 'alcazares' with triggerAsyncId derived // Create first custom event 'alcazares' with triggerAsyncId derived

View File

@ -10,7 +10,7 @@ const heartbeatMsg = /heartbeat: still alive/;
const { const {
newAsyncId, getDefaultTriggerAsyncId, newAsyncId, getDefaultTriggerAsyncId,
emitInit, emitBefore, emitAfter, emitDestroy emitInit, emitBefore, emitAfter, emitDestroy,
} = internal_async_hooks; } = internal_async_hooks;
const initHooks = require('./init-hooks'); const initHooks = require('./init-hooks');

View File

@ -30,7 +30,7 @@ const checkOnce = (fn) => {
initHooks({ initHooks({
onbefore: checkOnce(chkBefore), onbefore: checkOnce(chkBefore),
onafter: checkOnce(chkAfter), onafter: checkOnce(chkAfter),
allowNoInit: true allowNoInit: true,
}).enable(); }).enable();
async_hooks.emitInit(expectedId, expectedType, expectedTriggerId); async_hooks.emitInit(expectedId, expectedType, expectedTriggerId);

View File

@ -10,7 +10,7 @@ const heartbeatMsg = /heartbeat: still alive/;
const { const {
newAsyncId, getDefaultTriggerAsyncId, newAsyncId, getDefaultTriggerAsyncId,
emitInit, emitBefore, emitAfter, emitDestroy emitInit, emitBefore, emitAfter, emitDestroy,
} = internal_async_hooks; } = internal_async_hooks;
const initHooks = require('./init-hooks'); const initHooks = require('./init-hooks');

View File

@ -17,7 +17,7 @@ const hooks1 = initHooks({
assert.strictEqual(type, expectedType); assert.strictEqual(type, expectedType);
assert.strictEqual(triggerAsyncId, expectedTriggerId); assert.strictEqual(triggerAsyncId, expectedTriggerId);
assert.strictEqual(resource.key, expectedResource.key); assert.strictEqual(resource.key, expectedResource.key);
}) }),
}); });
hooks1.enable(); hooks1.enable();
@ -33,7 +33,7 @@ initHooks({
assert.strictEqual(type, expectedType); assert.strictEqual(type, expectedType);
assert.notStrictEqual(triggerAsyncId, expectedTriggerId); assert.notStrictEqual(triggerAsyncId, expectedTriggerId);
assert.strictEqual(resource.key, expectedResource.key); assert.strictEqual(resource.key, expectedResource.key);
}) }),
}).enable(); }).enable();
async_hooks.emitInit(expectedId, expectedType, null, expectedResource); async_hooks.emitInit(expectedId, expectedType, null, expectedResource);

View File

@ -5,7 +5,7 @@ const async_hooks = require('async_hooks');
const fs = require('fs'); const fs = require('fs');
const nestedHook = async_hooks.createHook({ const nestedHook = async_hooks.createHook({
init: common.mustNotCall() init: common.mustNotCall(),
}); });
let nestedCall = false; let nestedCall = false;
@ -16,7 +16,7 @@ async_hooks.createHook({
nestedCall = true; nestedCall = true;
fs.access(__filename, common.mustCall()); fs.access(__filename, common.mustCall());
} }
}, 2) }, 2),
}).enable(); }).enable();
fs.access(__filename, common.mustCall()); fs.access(__filename, common.mustCall());

View File

@ -17,7 +17,7 @@ const hooks = initHooks();
hooks.enable(); hooks.enable();
const { const {
HTTP2_HEADER_CONTENT_TYPE HTTP2_HEADER_CONTENT_TYPE,
} = http2.constants; } = http2.constants;
// Use large fixture to get several file operations. // Use large fixture to get several file operations.
@ -27,7 +27,7 @@ const fd = fs.openSync(fname, 'r');
const server = http2.createServer(); const server = http2.createServer();
server.on('stream', (stream) => { server.on('stream', (stream) => {
stream.respondWithFD(fd, { stream.respondWithFD(fd, {
[HTTP2_HEADER_CONTENT_TYPE]: 'text/plain' [HTTP2_HEADER_CONTENT_TYPE]: 'text/plain',
}); });
}); });
server.on('close', common.mustCall(() => fs.closeSync(fd))); server.on('close', common.mustCall(() => fs.closeSync(fd)));

View File

@ -21,6 +21,6 @@ function onexit() {
[ { type: 'FSREQCALLBACK', id: 'fsreq:1', triggerAsyncId: null }, [ { type: 'FSREQCALLBACK', id: 'fsreq:1', triggerAsyncId: null },
{ type: 'FSREQCALLBACK', id: 'fsreq:2', triggerAsyncId: 'fsreq:1' }, { type: 'FSREQCALLBACK', id: 'fsreq:2', triggerAsyncId: 'fsreq:1' },
{ type: 'FSREQCALLBACK', id: 'fsreq:3', triggerAsyncId: 'fsreq:2' }, { type: 'FSREQCALLBACK', id: 'fsreq:3', triggerAsyncId: 'fsreq:2' },
{ type: 'FSREQCALLBACK', id: 'fsreq:4', triggerAsyncId: 'fsreq:3' } ] { type: 'FSREQCALLBACK', id: 'fsreq:4', triggerAsyncId: 'fsreq:3' } ],
); );
} }

View File

@ -20,7 +20,7 @@ server.listen(0, common.mustCall(() => {
http.get({ http.get({
host: '::1', host: '::1',
family: 6, family: 6,
port: server.address().port port: server.address().port,
}, common.mustCall()); }, common.mustCall());
})); }));
@ -48,6 +48,6 @@ process.on('exit', () => {
triggerAsyncId: null }, triggerAsyncId: null },
{ type: 'SHUTDOWNWRAP', { type: 'SHUTDOWNWRAP',
id: 'shutdown:1', id: 'shutdown:1',
triggerAsyncId: 'tcp:2' } ] triggerAsyncId: 'tcp:2' } ],
); );
}); });

View File

@ -30,6 +30,6 @@ function onexit() {
verifyGraph( verifyGraph(
hooks, hooks,
[ { type: 'Timeout', id: 'timeout:1', triggerAsyncId: null }, [ { type: 'Timeout', id: 'timeout:1', triggerAsyncId: null },
{ type: 'Timeout', id: 'timeout:2', triggerAsyncId: 'timeout:1' }] { type: 'Timeout', id: 'timeout:2', triggerAsyncId: 'timeout:1' }],
); );
} }

View File

@ -27,6 +27,6 @@ function onexit() {
[ { type: 'PROCESSWRAP', id: 'process:1', triggerAsyncId: null }, [ { type: 'PROCESSWRAP', id: 'process:1', triggerAsyncId: null },
{ type: 'PIPEWRAP', id: 'pipe:1', triggerAsyncId: null }, { type: 'PIPEWRAP', id: 'pipe:1', triggerAsyncId: null },
{ type: 'PIPEWRAP', id: 'pipe:2', triggerAsyncId: null }, { type: 'PIPEWRAP', id: 'pipe:2', triggerAsyncId: null },
{ type: 'PIPEWRAP', id: 'pipe:3', triggerAsyncId: null } ] { type: 'PIPEWRAP', id: 'pipe:3', triggerAsyncId: null } ],
); );
} }

View File

@ -34,6 +34,6 @@ function onexit() {
{ type: 'PIPECONNECTWRAP', id: 'pipeconnect:1', { type: 'PIPECONNECTWRAP', id: 'pipeconnect:1',
triggerAsyncId: 'pipe:1' }, triggerAsyncId: 'pipe:1' },
{ type: 'PIPEWRAP', id: 'pipe:2', triggerAsyncId: 'pipeserver:1' }, { type: 'PIPEWRAP', id: 'pipe:2', triggerAsyncId: 'pipeserver:1' },
{ type: 'SHUTDOWNWRAP', id: 'shutdown:1', triggerAsyncId: 'pipe:2' } ] { type: 'SHUTDOWNWRAP', id: 'shutdown:1', triggerAsyncId: 'pipe:2' } ],
); );
} }

View File

@ -41,6 +41,6 @@ function onexit() {
{ type: 'TCPCONNECTWRAP', { type: 'TCPCONNECTWRAP',
id: 'tcpconnect:1', triggerAsyncId: 'tcp:1' }, id: 'tcpconnect:1', triggerAsyncId: 'tcp:1' },
{ type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: 'tcpserver:1' }, { type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: 'tcpserver:1' },
{ type: 'SHUTDOWNWRAP', id: 'shutdown:1', triggerAsyncId: 'tcp:2' } ] { type: 'SHUTDOWNWRAP', id: 'shutdown:1', triggerAsyncId: 'tcp:2' } ],
); );
} }

View File

@ -61,6 +61,6 @@ function onexit() {
{ type: 'PROCESSWRAP', id: 'process:3', triggerAsyncId: 'signal:1' }, { type: 'PROCESSWRAP', id: 'process:3', triggerAsyncId: 'signal:1' },
{ type: 'PIPEWRAP', id: 'pipe:7', triggerAsyncId: 'signal:1' }, { type: 'PIPEWRAP', id: 'pipe:7', triggerAsyncId: 'signal:1' },
{ type: 'PIPEWRAP', id: 'pipe:8', triggerAsyncId: 'signal:1' }, { type: 'PIPEWRAP', id: 'pipe:8', triggerAsyncId: 'signal:1' },
{ type: 'PIPEWRAP', id: 'pipe:9', triggerAsyncId: 'signal:1' } ] { type: 'PIPEWRAP', id: 'pipe:9', triggerAsyncId: 'signal:1' } ],
); );
} }

View File

@ -29,6 +29,6 @@ function onexit() {
verifyGraph( verifyGraph(
hooks, hooks,
[ { type: 'STATWATCHER', id: 'statwatcher:1', triggerAsyncId: null }, [ { type: 'STATWATCHER', id: 'statwatcher:1', triggerAsyncId: null },
{ type: 'STATWATCHER', id: 'statwatcher:2', triggerAsyncId: null } ] { type: 'STATWATCHER', id: 'statwatcher:2', triggerAsyncId: null } ],
); );
} }

View File

@ -43,6 +43,6 @@ function onexit() {
{ type: 'TCPCONNECTWRAP', { type: 'TCPCONNECTWRAP',
id: 'tcpconnect:1', triggerAsyncId: 'tcp:1' }, id: 'tcpconnect:1', triggerAsyncId: 'tcp:1' },
{ type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: 'tcpserver:1' }, { type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: 'tcpserver:1' },
{ type: 'SHUTDOWNWRAP', id: 'shutdown:1', triggerAsyncId: 'tcp:2' } ] { type: 'SHUTDOWNWRAP', id: 'shutdown:1', triggerAsyncId: 'tcp:2' } ],
); );
} }

View File

@ -27,6 +27,6 @@ function onexit() {
hooks, hooks,
[ { type: 'Timeout', id: 'timeout:1', triggerAsyncId: null }, [ { type: 'Timeout', id: 'timeout:1', triggerAsyncId: null },
{ type: 'Timeout', id: 'timeout:2', triggerAsyncId: 'timeout:1' }, { type: 'Timeout', id: 'timeout:2', triggerAsyncId: 'timeout:1' },
{ type: 'Timeout', id: 'timeout:3', triggerAsyncId: 'timeout:2' }] { type: 'Timeout', id: 'timeout:3', triggerAsyncId: 'timeout:2' }],
); );
} }

View File

@ -21,7 +21,7 @@ hooks.enable();
const server = tls const server = tls
.createServer({ .createServer({
cert: fixtures.readKey('rsa_cert.crt'), cert: fixtures.readKey('rsa_cert.crt'),
key: fixtures.readKey('rsa_private.pem') key: fixtures.readKey('rsa_private.pem'),
}) })
.on('listening', common.mustCall(onlistening)) .on('listening', common.mustCall(onlistening))
.on('secureConnection', common.mustCall(onsecureConnection)) .on('secureConnection', common.mustCall(onsecureConnection))
@ -66,6 +66,6 @@ function onexit() {
id: 'tcpconnect:1', triggerAsyncId: 'tcp:1' }, id: 'tcpconnect:1', triggerAsyncId: 'tcp:1' },
{ type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: 'tcpserver:1' }, { type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: 'tcpserver:1' },
{ type: 'TLSWRAP', id: 'tls:2', triggerAsyncId: 'tcpserver:1' }, { type: 'TLSWRAP', id: 'tls:2', triggerAsyncId: 'tcpserver:1' },
] ],
); );
} }

View File

@ -21,7 +21,7 @@ let responses = 0;
const agent = new http.Agent({ const agent = new http.Agent({
keepAlive: true, keepAlive: true,
keepAliveMsecs: Infinity, keepAliveMsecs: Infinity,
maxSockets: 1 maxSockets: 1,
}); });
const verifyRequest = (idx) => (res) => { const verifyRequest = (idx) => (res) => {
@ -58,13 +58,13 @@ const server = http.createServer(common.mustCall((req, res) => {
// First request. // First request.
const r1 = http.request({ const r1 = http.request({
agent, port, method: 'POST' agent, port, method: 'POST',
}, common.mustCall(verifyRequest(0))); }, common.mustCall(verifyRequest(0)));
r1.end(payload); r1.end(payload);
// Second request. Sent in parallel with the first one. // Second request. Sent in parallel with the first one.
const r2 = http.request({ const r2 = http.request({
agent, port, method: 'POST' agent, port, method: 'POST',
}, common.mustCall(verifyRequest(1))); }, common.mustCall(verifyRequest(1)));
r2.end(payload); r2.end(payload);
})); }));

View File

@ -20,7 +20,7 @@ let asyncIdAtSecondReq;
const agent = new http.Agent({ const agent = new http.Agent({
keepAlive: true, keepAlive: true,
keepAliveMsecs: Infinity, keepAliveMsecs: Infinity,
maxSockets: 1 maxSockets: 1,
}); });
const server = http.createServer(common.mustCall((req, res) => { const server = http.createServer(common.mustCall((req, res) => {
@ -38,7 +38,7 @@ const server = http.createServer(common.mustCall((req, res) => {
// First request. This is useless except for adding a socket to the // First request. This is useless except for adding a socket to the
// agents pool for reuse. // agents pool for reuse.
const r1 = http.request({ const r1 = http.request({
agent, port, method: 'POST' agent, port, method: 'POST',
}, common.mustCall((res) => { }, common.mustCall((res) => {
// Remember which socket we used. // Remember which socket we used.
const socket = res.socket; const socket = res.socket;
@ -60,8 +60,8 @@ const server = http.createServer(common.mustCall((req, res) => {
// response header has already been received. // response header has already been received.
const r2 = http.request({ const r2 = http.request({
agent, port, method: 'POST', headers: { agent, port, method: 'POST', headers: {
'Content-Length': payload.length 'Content-Length': payload.length,
} },
}, common.mustCall((res) => { }, common.mustCall((res) => {
asyncIdAtSecondReq = res.socket[async_id_symbol]; asyncIdAtSecondReq = res.socket[async_id_symbol];
assert.ok(asyncIdAtSecondReq > 0, `${asyncIdAtSecondReq} > 0`); assert.ok(asyncIdAtSecondReq > 0, `${asyncIdAtSecondReq} > 0`);

View File

@ -29,7 +29,7 @@ createHook({
if (resource[reused]) { if (resource[reused]) {
reusedParser.push( reusedParser.push(
`resource reused: ${asyncId}, ${triggerAsyncId}, ${type}` `resource reused: ${asyncId}, ${triggerAsyncId}, ${type}`,
); );
} }
resource[reused] = true; resource[reused] = true;
@ -40,7 +40,7 @@ createHook({
} else { } else {
destroyed.push(asyncId); destroyed.push(asyncId);
} }
} },
}).enable(); }).enable();
const server = http.createServer((req, res) => { const server = http.createServer((req, res) => {

View File

@ -16,7 +16,7 @@ const REQUEST = HTTPParser.REQUEST;
const kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0; const kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0;
const request = Buffer.from( const request = Buffer.from(
'GET /hello HTTP/1.1\r\n\r\n' 'GET /hello HTTP/1.1\r\n\r\n',
); );
const parser = new HTTPParser(); const parser = new HTTPParser();

View File

@ -21,7 +21,7 @@ const request = Buffer.from(
'Content-Type: text/plain\r\n' + 'Content-Type: text/plain\r\n' +
'Content-Length: 4\r\n' + 'Content-Length: 4\r\n' +
'\r\n' + '\r\n' +
'pong' 'pong',
); );
const parser = new HTTPParser(); const parser = new HTTPParser();

View File

@ -10,7 +10,7 @@ const heartbeatMsg = /heartbeat: still alive/;
const { const {
newAsyncId, getDefaultTriggerAsyncId, newAsyncId, getDefaultTriggerAsyncId,
emitInit, emitBefore, emitAfter emitInit, emitBefore, emitAfter,
} = internal_async_hooks; } = internal_async_hooks;
const initHooks = require('./init-hooks'); const initHooks = require('./init-hooks');

View File

@ -10,7 +10,7 @@ const heartbeatMsg = /heartbeat: still alive/;
const { const {
newAsyncId, getDefaultTriggerAsyncId, newAsyncId, getDefaultTriggerAsyncId,
emitInit, emitBefore, emitAfter emitInit, emitBefore, emitAfter,
} = internal_async_hooks; } = internal_async_hooks;
const initHooks = require('./init-hooks'); const initHooks = require('./init-hooks');

View File

@ -37,7 +37,7 @@ const hook = async_hooks.createHook({
destroy: common.mustCall(() => { destroy: common.mustCall(() => {
hook.disable(); hook.disable();
nextTest(); nextTest();
}, 3) }, 3),
}); });
nextTest(); nextTest();

View File

@ -23,6 +23,6 @@ process.on('exit', () => {
const as = hooks.activitiesOfTypes('TickObject'); const as = hooks.activitiesOfTypes('TickObject');
checkInvocations(as[0], { checkInvocations(as[0], {
init: 1, before: 1, after: 1, destroy: 1 init: 1, before: 1, after: 1, destroy: 1,
}, 'when process exits'); }, 'when process exits');
}); });

View File

@ -55,7 +55,7 @@ function onsleepClose() {
checkInvocations( checkInvocations(
processwrap, processwrap,
{ init: 1, before: 1, after: 1 }, { init: 1, before: 1, after: 1 },
'processwrap while in onsleepClose callback') 'processwrap while in onsleepClose callback'),
); );
} }

View File

@ -20,6 +20,6 @@ process.on('exit', () => {
const as = hooks.activitiesOfTypes('Microtask'); const as = hooks.activitiesOfTypes('Microtask');
checkInvocations(as[0], { checkInvocations(as[0], {
init: 1, before: 1, after: 1, destroy: 1 init: 1, before: 1, after: 1, destroy: 1,
}, 'when process exits'); }, 'when process exits');
}); });

View File

@ -25,7 +25,7 @@ tls.DEFAULT_MAX_VERSION = 'TLSv1.2';
const server = tls const server = tls
.createServer({ .createServer({
cert: fixtures.readKey('rsa_cert.crt'), cert: fixtures.readKey('rsa_cert.crt'),
key: fixtures.readKey('rsa_private.pem') key: fixtures.readKey('rsa_private.pem'),
}) })
.on('listening', common.mustCall(onlistening)) .on('listening', common.mustCall(onlistening))
.on('secureConnection', common.mustCall(onsecureConnection)) .on('secureConnection', common.mustCall(onsecureConnection))

View File

@ -35,7 +35,7 @@ const delayedOnCloseHandler = common.mustCall(() => {
}); });
process.stdin.on('error', (err) => assert.fail(err)); process.stdin.on('error', (err) => assert.fail(err));
process.stdin.on('close', common.mustCall(() => process.stdin.on('close', common.mustCall(() =>
tick(2, delayedOnCloseHandler) tick(2, delayedOnCloseHandler),
)); ));
process.stdin.destroy(); process.stdin.destroy();
checkInvocations(tty, checkInitOpts, 'when tty.end() was invoked'); checkInvocations(tty, checkInitOpts, 'when tty.end() was invoked');

View File

@ -15,7 +15,7 @@ const hooks = initHooks({
if (type === 'PROMISE') { if (type === 'PROMISE') {
promiseAsyncIds.push(asyncId); promiseAsyncIds.push(asyncId);
} }
} },
}); });
hooks.enable(); hooks.enable();

View File

@ -29,7 +29,7 @@ const buffers = {
writeResult: new Uint32Array(2), writeResult: new Uint32Array(2),
dictionary: new Uint8Array(0), dictionary: new Uint8Array(0),
inBuf: new Uint8Array([0x78]), inBuf: new Uint8Array([0x78]),
outBuf: new Uint8Array(1) outBuf: new Uint8Array(1),
}; };
handle.init( handle.init(
@ -39,7 +39,7 @@ handle.init(
constants.Z_DEFAULT_STRATEGY, constants.Z_DEFAULT_STRATEGY,
buffers.writeResult, buffers.writeResult,
function processCallback() { this.cb(); }, function processCallback() { this.cb(); },
buffers.dictionary buffers.dictionary,
); );
checkInvocations(hdl, { init: 1 }, 'when initialized handle'); checkInvocations(hdl, { init: 1 }, 'when initialized handle');

View File

@ -20,7 +20,7 @@ function pruneTickObjects(activities) {
const tickObject = { const tickObject = {
found: true, found: true,
index: null, index: null,
data: null data: null,
}; };
if (!Array.isArray(activities)) if (!Array.isArray(activities))
@ -42,7 +42,7 @@ function pruneTickObjects(activities) {
tickObject.data = activities[tickObject.index]; tickObject.data = activities[tickObject.index];
const triggerId = { const triggerId = {
new: tickObject.data.triggerAsyncId, new: tickObject.data.triggerAsyncId,
old: tickObject.data.uid old: tickObject.data.uid,
}; };
activities.forEach(function repointTriggerId(x) { activities.forEach(function repointTriggerId(x) {
@ -85,7 +85,7 @@ module.exports = function verifyGraph(hooks, graph) {
errors.push({ errors.push({
id: node.id, id: node.id,
expectedTid: node.triggerAsyncId, expectedTid: node.triggerAsyncId,
actualTid: uidtoid[x.triggerAsyncId] actualTid: uidtoid[x.triggerAsyncId],
}); });
} }
@ -93,8 +93,8 @@ module.exports = function verifyGraph(hooks, graph) {
errors.forEach((x) => errors.forEach((x) =>
console.error( console.error(
`'${x.id}' expected to be triggered by '${x.expectedTid}', ` + `'${x.id}' expected to be triggered by '${x.expectedTid}', ` +
`but was triggered by '${x.actualTid}' instead.` `but was triggered by '${x.actualTid}' instead.`,
) ),
); );
} }
assert.strictEqual(errors.length, 0); assert.strictEqual(errors.length, 0);