Skip to content

Commit

Permalink
Ignore load err that stops Python Ext from loading (#5146)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne authored Mar 17, 2021
1 parent 1bd421b commit d99989e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,6 @@ module.exports = {
'src/client/interpreter/display/progressDisplay.ts',
'src/client/interpreter/display/interpreterSelectionTip.ts',
'src/client/constants.ts',
'src/client/extension.ts',
'src/client/extensionInit.ts',
'src/client/sourceMapSupport.ts',
'src/client/startupTelemetry.ts',
Expand Down
1 change: 0 additions & 1 deletion .github/actions/create-venv-for-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,5 @@ runs:
python -m ipykernel install --user --name .venvnokernel --display-name .venvnokernel
python -m pip uninstall jedi --yes
python -m pip install jedi==0.17.2
python -m pip uninstall ipykernel --yes
working-directory: src/test/datascience
shell: bash
1 change: 1 addition & 0 deletions news/2 Fixes/5145.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure extensions depending on Jupyter do not fail to load if Jupyter extension fails to load.
37 changes: 25 additions & 12 deletions src/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { activateComponents } from './extensionActivation';
import { initializeGlobals } from './extensionInit';
import { IServiceContainer } from './ioc/types';
import { sendErrorTelemetry, sendStartupTelemetry } from './startupTelemetry';
import { noop } from './common/utils/misc';

durations.codeLoadingTime = stopWatch.elapsedTime;

Expand All @@ -49,24 +50,36 @@ let activatedServiceContainer: IServiceContainer | undefined;
// public functions

export async function activate(context: IExtensionContext): Promise<IExtensionApi> {
let api: IExtensionApi;
let ready: Promise<void>;
let serviceContainer: IServiceContainer;
try {
let api: IExtensionApi;
let ready: Promise<void>;
let serviceContainer: IServiceContainer;
[api, ready, serviceContainer] = await activateUnsafe(context, stopWatch, durations);
// Send the "success" telemetry only if activation did not fail.
// Otherwise Telemetry is send via the error handler.
sendStartupTelemetry(ready, durations, stopWatch, serviceContainer)
// Run in the background.
.ignoreErrors();
await ready;
return api;
} catch (ex) {
// We want to completely handle the error
// before notifying VS Code.
await handleError(ex, durations);
throw ex; // re-raise
traceError('Failed to active the Jupyter Extension', ex);
// Disable this, as we don't want Python extension or any other extensions that depend on this to fall over.
// Return a dummy object, to ensure other extension do not fall over.
return {
createBlankNotebook: () => Promise.resolve(),
onKernelStateChange: () => ({ dispose: noop }),
ready: Promise.resolve(),
registerCellToolbarButton: () => ({ dispose: noop }),
registerNewNotebookContent: () => Promise.resolve(),
registerPythonApi: noop,
registerRemoteServerProvider: noop,
showDataViewer: () => Promise.resolve()
};
}
// Send the "success" telemetry only if activation did not fail.
// Otherwise Telemetry is send via the error handler.
sendStartupTelemetry(ready, durations, stopWatch, serviceContainer)
// Run in the background.
.ignoreErrors();
await ready;
return api;
}

export function deactivate(): Thenable<void> {
Expand Down Expand Up @@ -114,7 +127,7 @@ async function activateUnsafe(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function displayProgress(promise: Promise<any>) {
const progressOptions: ProgressOptions = { location: ProgressLocation.Window, title: Common.loadingExtension() };
window.withProgress(progressOptions, () => promise);
window.withProgress(progressOptions, () => promise).then(noop, noop);
}

/////////////////////////////
Expand Down

0 comments on commit d99989e

Please sign in to comment.