From 661caa42af53177f7d977e2da10b212779c326e3 Mon Sep 17 00:00:00 2001 From: Sander Ronde Date: Mon, 24 Jun 2024 14:24:44 +0200 Subject: [PATCH] Improve behavior on WS disconnect for pro --- server/src/lib/phpstan/pro/proErrorManager.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/server/src/lib/phpstan/pro/proErrorManager.ts b/server/src/lib/phpstan/pro/proErrorManager.ts index f39f732..b69c355 100644 --- a/server/src/lib/phpstan/pro/proErrorManager.ts +++ b/server/src/lib/phpstan/pro/proErrorManager.ts @@ -98,6 +98,19 @@ export class PHPStanProErrorManager implements Disposable { this._connect(); } }); + // eslint-disable-next-line @typescript-eslint/no-misused-promises + this._wsClient.on('close', async () => { + const choice = + await this._classConfig.connection.window.showErrorMessage( + `PHPStan Pro disconnected from websocket URL: ${url}`, + { + title: 'Retry', + } + ); + if (choice?.title === 'Retry') { + this._connect(); + } + }); // eslint-disable-next-line @typescript-eslint/no-misused-promises this._wsClient.on('open', async () => { @@ -131,6 +144,11 @@ export class PHPStanProErrorManager implements Disposable { msg.action === 'analysisStart' || msg.action === 'changedFile' ) { + if (checkOperation) { + // Check already exists, finish that one + await onAnalysisDone(); + } + checkOperation = this._classConfig.statusBar.createOperation(); await Promise.all([ checkOperation.start('PHPStan Pro Checking...'),