Skip to content

Commit ea91e71

Browse files
authored
Properly terminate debug session if the workflow's webview panel is closed (#1584)
## Changes Before we were getting uncaught exceptions if users close webview panel, and the debug session was stuck forever (unless you click on the stop button manually) ## Tests Manually
1 parent 0edad31 commit ea91e71

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import {WorkspaceFsWorkflowWrapper} from "../workspace-fs/WorkspaceFsWorkflowWra
1919
import {BundleCommands} from "../ui/bundle-resource-explorer/BundleCommands";
2020
import {Events, Telemetry} from "../telemetry";
2121
import {ComputeType, WorkflowTaskType} from "../telemetry/constants";
22+
import {NamedLogger} from "@databricks/databricks-sdk/dist/logging";
23+
import {Loggers} from "../logger";
2224

2325
export class WorkflowRunner implements Disposable {
2426
private panels = new Map<string, WorkflowOutputPanel>();
@@ -209,7 +211,16 @@ export class WorkflowRunner implements Disposable {
209211
recordRun({success: true, taskType, computeType});
210212
}
211213
} catch (e: unknown) {
214+
this.handleRunError(panel, e);
215+
recordRun({success: false, taskType, computeType});
216+
}
217+
}
218+
219+
private handleRunError(panel: WorkflowOutputPanel, e: unknown) {
220+
const logger = NamedLogger.getOrCreate(Loggers.Extension);
221+
try {
212222
if (e instanceof ApiError) {
223+
logger.error("API error while running workflow:", e.message);
213224
panel.showError({
214225
message: e.message,
215226
stack:
@@ -219,11 +230,15 @@ export class WorkflowRunner implements Disposable {
219230
});
220231
panel.showStdoutResult(e.response.logs || "");
221232
} else {
233+
logger.error("Unexpected error while running workflow:", e);
222234
panel.showError({
223-
message: (e as any).message,
235+
message:
236+
(e as any)?.message || "An unknown error occurred.",
224237
});
225238
}
226-
recordRun({success: false, taskType, computeType});
239+
} catch (e) {
240+
// We can get here if posting a message to the webview throws an error (e.g. if it's closed)
241+
logger.error("Workflow error handling failed:", e);
227242
}
228243
}
229244
}

0 commit comments

Comments
 (0)