Skip to content

Commit 8362f88

Browse files
authored
Display error message when fetching script source timesout (#11276)
For #11242 * Add error for timeout * Add imports
1 parent 1ff9a19 commit 8362f88

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

src/client/datascience/ipywidgets/ipywidgetHandler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ export class IPyWidgetHandler implements IInteractiveWindowListener {
104104
sendTelemetryEvent(Telemetry.IPyWidgetLoadFailure, 0, {
105105
isOnline: payload.isOnline,
106106
moduleHash: this.hash(payload.moduleName),
107-
moduleVersion: payload.moduleVersion
107+
moduleVersion: payload.moduleVersion,
108+
timedout: payload.timedout
108109
});
109110
} catch {
110111
// do nothing on failure

src/client/telemetry/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1967,7 +1967,13 @@ export interface IEventNamePropertyMapping {
19671967
/**
19681968
* Telemetry event sent when an ipywidget module fails to load. Module name is hashed.
19691969
*/
1970-
[Telemetry.IPyWidgetLoadFailure]: { isOnline: boolean; moduleHash: string; moduleVersion: string };
1970+
[Telemetry.IPyWidgetLoadFailure]: {
1971+
isOnline: boolean;
1972+
moduleHash: string;
1973+
moduleVersion: string;
1974+
// Whether we timedout getting the source of the script (fetching script source in extension code).
1975+
timedout: boolean;
1976+
};
19711977
/**
19721978
* Telemetry event sent when an loading of 3rd party ipywidget JS scripts from 3rd party source has been disabled.
19731979
*/

src/datascience-ui/interactive-common/redux/reducers/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ export interface ILoadIPyWidgetClassFailureAction {
220220
isOnline: boolean;
221221
// tslint:disable-next-line: no-any
222222
error: any;
223+
timedout: boolean;
223224
}
224225
export type LoadIPyWidgetClassDisabledAction = {
225226
className: string;

src/datascience-ui/ipywidgets/container.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import * as isonline from 'is-online';
77
import * as React from 'react';
88
import { Store } from 'redux';
9+
import '../../client/common/extensions';
910
import { createDeferred, Deferred } from '../../client/common/utils/async';
1011
import {
1112
IInteractiveWindowMapping,
@@ -137,7 +138,8 @@ export class WidgetManagerComponent extends React.Component<Props> {
137138
moduleVersion: string,
138139
isOnline: boolean,
139140
// tslint:disable-next-line: no-any
140-
error: any
141+
error: any,
142+
timedout: boolean
141143
): CommonAction<ILoadIPyWidgetClassFailureAction> {
142144
return {
143145
type: CommonActionType.LOAD_IPYWIDGET_CLASS_FAILURE,
@@ -148,16 +150,25 @@ export class WidgetManagerComponent extends React.Component<Props> {
148150
moduleName,
149151
moduleVersion,
150152
isOnline,
153+
timedout,
151154
error,
152155
cdnsUsed: this.widgetsCanLoadFromCDN
153156
}
154157
}
155158
};
156159
}
157-
// tslint:disable-next-line: no-any
158-
private async handleLoadError(className: string, moduleName: string, moduleVersion: string, error: any) {
160+
private async handleLoadError(
161+
className: string,
162+
moduleName: string,
163+
moduleVersion: string,
164+
// tslint:disable-next-line: no-any
165+
error: any,
166+
timedout: boolean = false
167+
) {
159168
const isOnline = await isonline.default({ timeout: 1000 });
160-
this.props.store.dispatch(this.createLoadErrorAction(className, moduleName, moduleVersion, isOnline, error));
169+
this.props.store.dispatch(
170+
this.createLoadErrorAction(className, moduleName, moduleVersion, isOnline, error, timedout)
171+
);
161172
}
162173

163174
/**
@@ -188,6 +199,7 @@ export class WidgetManagerComponent extends React.Component<Props> {
188199
setTimeout(() => {
189200
// tslint:disable-next-line: no-console
190201
console.error(`Timeout waiting to get widget source for ${moduleName}, ${moduleVersion}`);
202+
this.handleLoadError('<class>', moduleName, moduleVersion, new Error('Timeout'), true).ignoreErrors();
191203
if (deferred) {
192204
deferred.resolve();
193205
}

0 commit comments

Comments
 (0)