Skip to content

Commit a906f27

Browse files
author
Tim Etchells
committed
Reject pending restart if Microclimate disconnects
Fixes #17
1 parent 8ac2692 commit a906f27

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

dev/src/constants/strings/strings-en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@
9191
"restartFailure": "Failed to restart {{ projectName }} in {{ startMode }} mode.",
9292
"restartFailureWithReason": "Failed to restart {{ projectName }} in {{ startMode }} mode: {{ reason }}.",
9393
"restartFailedReasonDebugFailure": "attaching the debugger failed. Try attaching the debugger again",
94-
"restartFailedReasonTimeout": "failed to restart within {{ timeoutS }} seconds"
94+
"restartFailedReasonTimeout": "failed to restart within {{ timeoutS }} seconds",
95+
"restartFailedReasonDisconnect": "Microclimate disconnected"
9596
},
9697

9798
"openInBrowserCmd": {

dev/src/microclimate/connection/Connection.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,10 @@ export default class Connection implements ITreeItemAdaptable, vscode.QuickPickI
122122
return;
123123
}
124124
this.connected = false;
125+
126+
this.projects.forEach((p) => p.onConnectionDisconnect());
125127
this.projects = [];
128+
126129
Log.d(`${this} is now disconnected`);
127130
this.logManager.onConnectionDisconnect();
128131

dev/src/microclimate/project/Project.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ export default class Project implements ITreeItemAdaptable, vscode.QuickPickItem
135135
}
136136
}
137137

138+
public onConnectionDisconnect(): void {
139+
if (this.pendingRestart != null) {
140+
this.pendingRestart.onConnectionDisconnect();
141+
}
142+
}
143+
138144
/**
139145
* Set this project's status based on the project info event payload passed.
140146
* This includes checking the appStatus, buildStatus, buildStatusDetail, and startMode.

dev/src/microclimate/project/ProjectPendingRestart.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,18 @@ export default class ProjectPendingRestart {
163163
}
164164
}
165165

166+
public onConnectionDisconnect(): void {
167+
this.fulfill(false, Translator.t(STRING_NS, "restartFailedReasonDisconnect"));
168+
}
169+
166170
/**
167171
* Resolves this class's restart promise, removing the status bar item and rendering this pending restart "done".
168172
* Also calls onRestartFinish which removes the Project's reference to this instance.
169173
*
170174
* Displays a success or failure message to the user depending on the value of `success`.
171175
*/
172176
private fulfill(success: boolean, error?: string): void {
173-
Log.d("Fulfilling pending restart for " + this.project.name);
177+
Log.d(`Fulfilling pending restart for ${this.project.name}, success=${success}${error ? ", error=" + error : ""}`);
174178

175179
if (this.resolve == null || this.timeoutID == null) {
176180
// will never happen

0 commit comments

Comments
 (0)