mirror of
https://github.com/nodejs/node.git
synced 2025-05-20 22:43:26 +00:00

This makes sure that all async functions finish as expected. PR-URL: https://github.com/nodejs/node/pull/34363 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
|
|
common.skipIfInspectorDisabled();
|
|
|
|
const assert = require('assert');
|
|
const { spawnSync } = require('child_process');
|
|
|
|
(async function test() {
|
|
await testArg('stderr');
|
|
await testArg('http');
|
|
await testArg('http,stderr');
|
|
})().then(common.mustCall());
|
|
|
|
async function testArg(argValue) {
|
|
console.log('Checks ' + argValue + '..');
|
|
const hasHttp = argValue.split(',').includes('http');
|
|
const hasStderr = argValue.split(',').includes('stderr');
|
|
|
|
const nodeProcess = spawnSync(process.execPath, [
|
|
'--inspect=0',
|
|
`--inspect-publish-uid=${argValue}`,
|
|
'-e', `(${scriptMain.toString()})(${hasHttp ? 200 : 404})`
|
|
]);
|
|
const hasWebSocketInStderr = checkStdError(
|
|
nodeProcess.stderr.toString('utf8'));
|
|
assert.strictEqual(hasWebSocketInStderr, hasStderr);
|
|
|
|
function checkStdError(data) {
|
|
const matches = data.toString('utf8').match(/ws:\/\/.+:(\d+)\/.+/);
|
|
return !!matches;
|
|
}
|
|
|
|
function scriptMain(code) {
|
|
const url = require('inspector').url();
|
|
const { host } = require('url').parse(url);
|
|
require('http').get('http://' + host + '/json/list', (response) => {
|
|
assert.strictEqual(response.statusCode, code);
|
|
response.destroy();
|
|
});
|
|
}
|
|
}
|