Skip to content

Commit

Permalink
Improve behavior on WS disconnect for pro
Browse files Browse the repository at this point in the history
  • Loading branch information
Sander Ronde committed Jun 24, 2024
1 parent ea1cfde commit 661caa4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions server/src/lib/phpstan/pro/proErrorManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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...'),
Expand Down

0 comments on commit 661caa4

Please sign in to comment.