Fix dependabot issues

This commit is contained in:
Andrew Eisenberg 2021-10-21 15:24:20 -07:00
parent c89d9bd8b0
commit 531c6ba7c8
705 changed files with 53406 additions and 20466 deletions

View file

@ -32,6 +32,8 @@ ipc.options.then(async options => {
const dependencyTracking = require('./dependency-tracker');
const lineNumberSelection = require('./line-numbers');
const sharedWorkerTeardowns = [];
async function exit(code) {
if (!process.exitCode) {
process.exitCode = code;
@ -89,10 +91,12 @@ ipc.options.then(async options => {
exit(1);
});
runner.on('finish', () => {
runner.on('finish', async () => {
try {
const touchedFiles = runner.saveSnapshotState();
if (touchedFiles) {
const {cannotSave, touchedFiles} = runner.saveSnapshotState();
if (cannotSave) {
ipc.send({type: 'snapshot-error'});
} else if (touchedFiles) {
ipc.send({type: 'touched-files', files: touchedFiles});
}
} catch (error) {
@ -101,6 +105,14 @@ ipc.options.then(async options => {
return;
}
try {
await Promise.all(sharedWorkerTeardowns.map(fn => fn()));
} catch (error) {
ipc.send({type: 'uncaught-exception', err: serializeError('Shared worker teardown error', false, error, runner.file)});
exit(1);
return;
}
nowAndTimers.setImmediate(() => {
currentlyUnhandled()
.filter(rejection => !attributedRejections.has(rejection.promise))
@ -127,6 +139,19 @@ ipc.options.then(async options => {
return runner;
};
exports.registerSharedWorker = (filename, initialData, teardown) => {
const {channel, forceUnref, ready} = ipc.registerSharedWorker(filename, initialData);
runner.waitForReady.push(ready);
sharedWorkerTeardowns.push(async () => {
try {
await teardown();
} finally {
forceUnref();
}
});
return channel;
};
// Store value to prevent required modules from modifying it.
const testPath = options.file;
@ -196,15 +221,21 @@ ipc.options.then(async options => {
if (Reflect.has(mod, Symbol.for('esm:package'))) {
requireFn = mod(module);
}
} catch (_) {}
} catch {}
}
// Install dependency tracker after the require configuration has been evaluated
// to make sure we also track dependencies with custom require hooks
dependencyTracking.install(testPath);
if (options.debug) {
require('inspector').open(options.debug.port, options.debug.host, true); // eslint-disable-line node/no-unsupported-features/node-builtins
if (options.debug && options.debug.port !== undefined && options.debug.host !== undefined) {
// If an inspector was active when the main process started, and is
// already active for the worker process, do not open a new one.
const inspector = require('inspector'); // eslint-disable-line node/no-unsupported-features/node-builtins
if (!options.debug.active || inspector.url() === undefined) {
inspector.open(options.debug.port, options.debug.host, true);
}
if (options.debug.break) {
debugger; // eslint-disable-line no-debugger
}