Skip to content

Commit d090ec7

Browse files
authored
Cancel workflow run if the webview panel is closed before the run even started (#1365)
## Changes Cancel workflow run if the webview panel is closed before the run even started ## Tests Manually
1 parent e51e62b commit d090ec7

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

packages/databricks-vscode/src/run/WorkflowRunner.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,11 @@ export class WorkflowRunner implements Disposable {
8181
}) {
8282
const panel = await this.getPanelForUri(program.uri);
8383

84-
const cancellation = new CancellationTokenSource();
85-
panel.onDidDispose(() => cancellation.cancel());
84+
const panelCancellation = new CancellationTokenSource();
85+
panel.onDidDispose(() => panelCancellation.cancel());
8686

8787
if (token) {
88-
token.onCancellationRequested(() => {
89-
cancellation.cancel();
90-
});
88+
token.onCancellationRequested(() => panelCancellation.cancel());
9189
}
9290

9391
try {
@@ -100,6 +98,11 @@ export class WorkflowRunner implements Disposable {
10098
}
10199
return;
102100
}
101+
102+
if (panelCancellation.token.isCancellationRequested) {
103+
return;
104+
}
105+
103106
if (token?.isCancellationRequested) {
104107
panel.showError({
105108
message: "Execution terminated by user.",
@@ -159,7 +162,7 @@ export class WorkflowRunner implements Disposable {
159162
) => {
160163
panel.updateState(cluster, state, run);
161164
},
162-
token: cancellation.token,
165+
token: panelCancellation.token,
163166
})
164167
);
165168
} else {
@@ -184,7 +187,7 @@ export class WorkflowRunner implements Disposable {
184187
) => {
185188
panel.updateState(cluster, state, run);
186189
},
187-
token: cancellation.token,
190+
token: panelCancellation.token,
188191
});
189192
//TODO: Respone logs will contain bootstrap code path in the error stack trace. Remove it.
190193
panel.showStdoutResult(response.logs || "");

0 commit comments

Comments
 (0)