Skip to content

Commit

Permalink
fix: re-add teardown
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Mar 20, 2023
1 parent 6b2e859 commit 82fa4e3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,18 @@ export const watch = (

const watcher = new Watcher(project);

let shuttingDown = false;

const shutdown = async () => {
if (shuttingDown) {
return;
}

shuttingDown = true;

// eslint-disable-next-line promise/prefer-await-to-then
await watcher.close();

clearInterval(indexingIntervalId);

abortController.abort();
Expand All @@ -70,8 +81,13 @@ export const watch = (
}
}

// eslint-disable-next-line promise/prefer-await-to-then
await watcher.close();
for (const subscription of subscriptions) {
const { teardown } = subscription;

if (teardown) {
await teardown();
}
}
};

if (abortSignal) {
Expand Down

0 comments on commit 82fa4e3

Please sign in to comment.