66import * as isonline from 'is-online' ;
77import * as React from 'react' ;
88import { Store } from 'redux' ;
9+ import '../../client/common/extensions' ;
910import { createDeferred , Deferred } from '../../client/common/utils/async' ;
1011import {
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