Skip to content

Commit 1fb0799

Browse files
authored
Add more logging around jupyter server death (microsoft#4663)
For #4573, #4497 Add more logging around server death and connection problems. Make kernel spec connection problems not cause server crash Also adjust the version of 'ws' in use. <!-- If an item below does not apply to you, then go ahead and check it off as "done" and strikethrough the text, e.g.: - [x] ~Has unit tests & system/integration tests~ --> - [ ] Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR) - [x] Title summarizes what is changing - [x] Has a [news entry](https://github.com/Microsoft/vscode-python/tree/master/news) file (remember to thank yourself!) - [ ] Has sufficient logging. - [ ] Has telemetry for enhancements. - [ ] Unit tests & system/integration tests are added/updated - [ ] [Test plan](https://github.com/Microsoft/vscode-python/blob/master/.github/test_plan.md) is updated as appropriate - [x] [`package-lock.json`](https://github.com/Microsoft/vscode-python/blob/master/package-lock.json) has been regenerated by running `npm install` (if dependencies have changed) - [ ] The wiki is updated with any design decisions/details.
1 parent ffb5173 commit 1fb0799

18 files changed

Lines changed: 369 additions & 132 deletions

File tree

news/3 Code Health/4497.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Force WS to at least 6.2 to alleviate security concerns.

news/3 Code Health/4573.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add more logging for ECONNREFUSED errors and Jupyter server crashes

package-lock.json

Lines changed: 25 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2168,7 +2168,7 @@
21682168
"updateBuildNumber": "gulp updateBuildNumber"
21692169
},
21702170
"dependencies": {
2171-
"@jupyterlab/services": "^3.1.4",
2171+
"@jupyterlab/services": "^3.2.1",
21722172
"arch": "^2.1.0",
21732173
"azure-storage": "^2.10.1",
21742174
"diff-match-patch": "^1.0.0",
@@ -2207,6 +2207,7 @@
22072207
"vscode-languageserver-protocol": "^3.10.3",
22082208
"vsls": "^0.3.1291",
22092209
"winreg": "^1.2.4",
2210+
"ws": "^6.2.0",
22102211
"xml2js": "^0.4.19"
22112212
},
22122213
"devDependencies": {

package.nls.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@
9797
"DataScience.notebookCheckForImportTitle": "Do you want to import the Jupyter Notebook into Python code?",
9898
"DataScience.jupyterNotSupported": "Running cells requires Jupyter notebooks to be installed.",
9999
"DataScience.jupyterNbConvertNotSupported": "Importing notebooks requires Jupyter nbconvert to be installed.",
100-
"DataScience.jupyterLaunchTimedOut": "The Jupyter notebook server failed to launch in time",
101100
"DataScience.jupyterLaunchNoURL": "Failed to find the URL of the launched Jupyter notebook server",
101+
"DataScience.jupyterLaunchTimedOut": "The Jupyter notebook server failed to launch in time",
102+
"DataScience.jupyterServerCrashed": "Jupyter server crashed. Unable to connect. \r\nError code from jupyter: {0}",
102103
"DataScience.pythonInteractiveHelpLink": "Get more help",
103104
"DataScience.importingFormat": "Importing {0}",
104105
"DataScience.startingJupyter": "Starting Jupyter server",
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This file can mimic juypter running. Useful for testing jupyter crash handling
2+
3+
import sys
4+
import argparse
5+
import time
6+
7+
def main():
8+
print('hello from dummy jupyter')
9+
parser = argparse.ArgumentParser()
10+
parser.add_argument('--version', type=bool, default=False, const=True, nargs='?')
11+
parser.add_argument('notebook', type=bool, default=False, const=True, nargs='?')
12+
parser.add_argument('--no-browser', type=bool, default=False, const=True, nargs='?')
13+
parser.add_argument('--notebook-dir', default='')
14+
parser.add_argument('--config', default='')
15+
results = parser.parse_args()
16+
if (results.version):
17+
print('1.1.dummy')
18+
else:
19+
print('http://localhost:8888/?token=012f08663a68e279fe0a5335e0b5dfe44759ddcccf0b3a56')
20+
time.sleep(5)
21+
raise Exception('Dummy is dead')
22+
23+
24+
if __name__ == '__main__':
25+
main()

src/client/common/application/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,11 @@ export interface IWebPanel {
851851
* Sends a message to the hosted html page
852852
*/
853853
postMessage(message: WebPanelMessage): void;
854+
855+
/**
856+
* Attempts to close the panel if it's visible
857+
*/
858+
close(): void;
854859
}
855860

856861
// Wraps the VS Code api for creating a web panel

src/client/common/application/webPanel.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ export class WebPanel implements IWebPanel {
5151
}
5252
}
5353

54+
public close() {
55+
if (this.panel) {
56+
this.panel.dispose();
57+
}
58+
}
59+
5460
public isVisible() : boolean {
5561
return this.panel ? this.panel.visible : false;
5662
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
3-
43
'use strict';
5-
64
import { inject, injectable } from 'inversify';
5+
76
import { IServiceContainer } from '../../ioc/types';
8-
import { IWebPanelMessageListener, IWebPanelProvider } from './types';
7+
import { IWebPanel, IWebPanelMessageListener, IWebPanelProvider } from './types';
98
import { WebPanel } from './webPanel';
109

1110
@injectable()
@@ -14,7 +13,7 @@ export class WebPanelProvider implements IWebPanelProvider {
1413
}
1514

1615
// tslint:disable-next-line:no-any
17-
public create(listener: IWebPanelMessageListener, title: string, mainScriptPath: string, embeddedCss?: string, settings?: any) {
16+
public create(listener: IWebPanelMessageListener, title: string, mainScriptPath: string, embeddedCss?: string, settings?: any) : IWebPanel {
1817
return new WebPanel(this.serviceContainer, listener, title, mainScriptPath, embeddedCss, settings);
1918
}
2019
}

src/client/common/utils/localize.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export namespace DataScience {
113113
export const jupyterSelectURIInvalidURI = localize('DataScience.jupyterSelectURIInvalidURI', 'Invalid URI specified');
114114
export const jupyterNotebookFailure = localize('DataScience.jupyterNotebookFailure', 'Jupyter notebook failed to launch. \r\n{0}');
115115
export const jupyterNotebookConnectFailed = localize('DataScience.jupyterNotebookConnectFailed', 'Failed to connect to Jupyter notebook. \r\n{0}\r\n{1}');
116+
export const jupyterServerCrashed = localize('DataScience.jupyterServerCrashed', 'Jupyter server crashed. Unable to connect. \r\nError code from jupyter: {0}');
116117
export const notebookVersionFormat = localize('DataScience.notebookVersionFormat', 'Jupyter Notebook Version: {0}');
117118
//tslint:disable-next-line:no-multiline-string
118119
export const jupyterKernelNotSupportedOnActive = localize('DataScience.jupyterKernelNotSupportedOnActive', `iPython kernel cannot be started from '{0}'. Using closest match {1} instead.`);

0 commit comments

Comments
 (0)