Skip to content

Commit

Permalink
Intercept debugpyAttach message to avoid error (#12498)
Browse files Browse the repository at this point in the history
for unsupported subprocess debugging
For #9886
  • Loading branch information
roblourens authored Jan 7, 2023
1 parent 80be6c4 commit 03937ba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/interactive-window/debugger/jupyter/debugCellController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { NotebookCell } from 'vscode';
import { DebugProtocol } from 'vscode-debugprotocol';
import { INotebookKernelExecution } from '../../../kernels/types';
import { DebuggingTelemetry } from '../../../notebooks/debugger/constants';
import { isJustMyCodeNotification } from '../../../notebooks/debugger/controllers/debugCellController';
import {
isDebugpyAttachRequest,
isJustMyCodeNotification
} from '../../../notebooks/debugger/controllers/debugCellController';
import { IDebuggingDelegate, IKernelDebugAdapter } from '../../../notebooks/debugger/debuggingTypes';
import { cellDebugSetup } from '../../../notebooks/debugger/helper';
import { createDeferred } from '../../../platform/common/utils/async';
Expand Down Expand Up @@ -35,6 +38,11 @@ export class DebugCellController implements IDebuggingDelegate {
}

public async willSendEvent(msg: DebugProtocol.Event): Promise<boolean> {
if (isDebugpyAttachRequest(msg)) {
this.trace('intercept', 'debugpyAttach request for subprocess, not supported');
return true;
}

if (msg.event === 'output') {
if (isJustMyCodeNotification(msg.body.output)) {
this.trace('intercept', 'justMyCode notification');
Expand Down
9 changes: 9 additions & 0 deletions src/notebooks/debugger/controllers/debugCellController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export function isJustMyCodeNotification(msg: string): boolean {
return msg.includes('Frame skipped from debugging during step-in');
}

export function isDebugpyAttachRequest(msg: DebugProtocol.Event): boolean {
return msg.event === 'debugpyAttach';
}

/**
* Controls starting execution on a cell when debugging a cell.
*/
Expand All @@ -34,6 +38,11 @@ export class DebugCellController implements IDebuggingDelegate {
}

public async willSendEvent(msg: DebugProtocol.Event): Promise<boolean> {
if (isDebugpyAttachRequest(msg)) {
this.trace('intercept', 'debugpyAttach request for subprocess, not supported');
return true;
}

if (msg.event === 'output') {
if (isJustMyCodeNotification(msg.body.output)) {
this.trace('intercept', 'justMyCode notification');
Expand Down

0 comments on commit 03937ba

Please sign in to comment.