mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
dispose Mocha Runner after use to avoid MaxlistenersExceededWarning (#41403)
* dispose Mocha Runner after use to avoid MaxlistenersExceededWarning - removed manual `unhandledRejection` listener as Mocha v8.2.0 now has one * Remove ts-ignore comment and commented out line. Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
b5b0437a86
commit
40adb27799
@@ -210,12 +210,10 @@ namespace Harness.Parallel.Worker {
|
||||
const passes: TestInfo[] = [];
|
||||
const start = +new Date();
|
||||
const runner = new Mocha.Runner(suite, /*delay*/ false);
|
||||
const uncaught = (err: any) => runner.uncaught(err);
|
||||
|
||||
runner
|
||||
.on("start", () => {
|
||||
unhookUncaughtExceptions(); // turn off global uncaught handling
|
||||
process.on("unhandledRejection", uncaught); // turn on unhandled rejection handling (not currently handled in mocha)
|
||||
})
|
||||
.on("pass", (test: Mocha.Test) => {
|
||||
passes.push({ name: test.titlePath() });
|
||||
@@ -224,8 +222,8 @@ namespace Harness.Parallel.Worker {
|
||||
errors.push({ name: test.titlePath(), error: err.message, stack: err.stack });
|
||||
})
|
||||
.on("end", () => {
|
||||
process.removeListener("unhandledRejection", uncaught);
|
||||
hookUncaughtExceptions();
|
||||
runner.dispose();
|
||||
})
|
||||
.run(() => {
|
||||
fn({ task, errors, passes, passing: passes.length, duration: +new Date() - start });
|
||||
|
||||
Reference in New Issue
Block a user