From 32f282fc2163f9088803995536c2b461594e0d66 Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Wed, 6 Dec 2023 22:18:23 +0100 Subject: [PATCH] Ensure watch mode works outside of its integration tests Somewhere between developing the watch mode and adding test coverage, a mechanism was introduced to control watch mode in its integration tests. Ironically watch mode relied on this mechanism and no longer worked in actual use. Fixes #3270 --- lib/cli.js | 2 +- lib/watcher.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index cc00b45a3..e517acc6e 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -522,7 +522,7 @@ export default async function loadCli() { // eslint-disable-line complexity providers, reporter, stdin: process.stdin, - signal: abortController.signal, + signal: abortController?.signal, }); } else { let debugWithoutSpecificFile = false; diff --git a/lib/watcher.js b/lib/watcher.js index 470a32229..cf29c5518 100644 --- a/lib/watcher.js +++ b/lib/watcher.js @@ -370,15 +370,15 @@ async function * plan({api, filter, globs, projectDir, providers, stdin, abortSi } }); - abortSignal.addEventListener('abort', () => { + abortSignal?.addEventListener('abort', () => { signalChanged?.({}); }); // And finally, the watch loop. - while (!abortSignal.aborted) { + while (abortSignal?.aborted !== true) { const {testFiles: files = [], runOnlyExclusive = false} = await changed; // eslint-disable-line no-await-in-loop - if (abortSignal.aborted) { + if (abortSignal?.aborted) { break; }