Skip to content

Commit

Permalink
fix(nxls): use native watcher right away when daemon dies during watc…
Browse files Browse the repository at this point in the history
…h process (#2351)
  • Loading branch information
MaxKless authored Dec 9, 2024
1 parent 8ed9385 commit ab5537c
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions libs/language-server/watcher/src/lib/daemon-watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class DaemonWatcher {
if (error === 'closed') {
if (!this.stopped) {
lspLogger.log('Daemon watcher connection closed, restarting');
this.tryRestartWatcher();
this.useNativeWatcher();
}
} else if (error) {
lspLogger.log('Error watching files: ' + error);
Expand Down Expand Up @@ -142,24 +142,8 @@ export class DaemonWatcher {
lspLogger.log(
`Error initializing daemon watcher, check daemon logs. ${e}`
);
this.tryRestartWatcher();
}
}

private async tryRestartWatcher() {
this.disposeEverything();
if (this.retryCount > 0) {
lspLogger.log('Daemon watcher failed to restart, using native watcher');
this.useNativeWatcher();
return;
}
this.retryCount++;
await new Promise((resolve) => {
const timeout = setTimeout(resolve, 100);
this.disposables.add(() => clearTimeout(timeout));
});

await this.initWatcher();
}

private useNativeWatcher() {
Expand Down

0 comments on commit ab5537c

Please sign in to comment.