Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn when unable to identify caller #15286

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"theme": "light"
},
"engines": {
"vscode": "^1.88.0"
"vscode": "^1.87.0"
},
"l10n": "./l10n",
"extensionKind": [
Expand Down
18 changes: 12 additions & 6 deletions src/platform/common/application/extensions.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { IExtensions } from '../types';
import { DataScience } from '../utils/localize';
import { parseStack } from '../../errors';
import { JVSC_EXTENSION_ID, unknownExtensionId } from '../constants';
import { traceError } from '../../logging';
import { traceError, traceWarning } from '../../logging';

/**
* Provides functions for tracking the list of extensions that VS code has installed (besides our own)
Expand All @@ -17,24 +17,27 @@ export class Extensions implements IExtensions {
public determineExtensionFromCallStack(stack?: string): { extensionId: string; displayName: string } {
stack = stack || new Error().stack;
try {
let frames: string[] = [];
const jupyterExtRoot = extensions.getExtension(JVSC_EXTENSION_ID)!.extensionUri.toString().toLowerCase();
if (stack) {
const jupyterExtRoot = extensions
.getExtension(JVSC_EXTENSION_ID)!
.extensionUri.toString()
.toLowerCase();
const frames = stack
frames = stack
.split('\n')
.map((f) => {
const result = /\((.*)\)/.exec(f);
if (result) {
return result[1];
} else {
traceWarning(`Regex failed to parse stack frame ${f}`);
}
})
.filter((item) => item && !item.toLowerCase().startsWith(jupyterExtRoot)) as string[];
parseStack(new Error('Ex')).forEach((item) => {
const fileName = item.getFileName();
if (fileName && !fileName.toLowerCase().startsWith(jupyterExtRoot)) {
frames.push(fileName);
traceWarning(`Parsed file name in stack ${fileName}`);
} else {
traceWarning(`Unable to parse file name in stack`);
}
});
for (const frame of frames) {
Expand All @@ -49,6 +52,9 @@ export class Extensions implements IExtensions {
}
}
}
traceError(`Unable to determine the caller of the extension API for trace stack.`, stack);
traceError(`Frames.`, frames.join(', '));
traceError(`Jupyter Extension Root.`, jupyterExtRoot);
return { extensionId: unknownExtensionId, displayName: DataScience.unknownPackage };
} catch (ex) {
traceError(`Unable to determine the caller of the extension API for trace stack.`, stack);
Expand Down
Loading