Don't log race condition error (#14922)

This commit is contained in:
Charles Gagnon
2021-04-01 11:11:43 -07:00
committed by GitHub
parent 97ce7b9b67
commit 4c2969d4ca
3 changed files with 12 additions and 3 deletions

View File

@@ -17,7 +17,10 @@ export function subscriptionToDisposable(sub: Subscription): IDisposable {
} }
export class AngularDisposable extends Disposable implements OnDestroy { export class AngularDisposable extends Disposable implements OnDestroy {
public isDisposed = false;
ngOnDestroy() { ngOnDestroy() {
this.dispose(); this.dispose();
this.isDisposed = true;
} }
} }

View File

@@ -110,7 +110,7 @@ export class ModelComponentWrapper extends AngularDisposable implements AfterVie
let selector = componentRegistry.getCtorFromId(this.descriptor.type); let selector = componentRegistry.getCtorFromId(this.descriptor.type);
if (selector === undefined) { if (selector === undefined) {
this.logService.error('No selector defined for type {0}', this.descriptor.type); this.logService.error('No selector defined for type ', this.descriptor.type);
return; return;
} }
@@ -128,7 +128,13 @@ export class ModelComponentWrapper extends AngularDisposable implements AfterVie
this._componentInstance.modelStore = this.modelStore; this._componentInstance.modelStore = this.modelStore;
this._changeref.detectChanges(); this._changeref.detectChanges();
} catch (e) { } catch (e) {
this.logService.error('Error rendering component: {0}', e); // There's a possible race condition here where a component that is added is then immediately removed,
// which then makes it so that while the changeRef isn't destroyed when we call detectChanges above
// it becomes destroyed during the detectChanges call and thus eventually throws. So to avoid a pointless
// error message in the console we just make sure that we aren't disposed before printing it out
if (!this.isDisposed) {
this.logService.error('Error rendering component: ', e);
}
return; return;
} }
let el = <HTMLElement>componentRef.location.nativeElement; let el = <HTMLElement>componentRef.location.nativeElement;

View File

@@ -1118,7 +1118,7 @@ export class NotebookModel extends Disposable implements INotebookModel {
} }
await this.shutdownActiveSession(); await this.shutdownActiveSession();
} catch (err) { } catch (err) {
this.logService.error('An error occurred when closing the notebook: {0}', getErrorMessage(err)); this.logService.error('An error occurred when closing the notebook: ', getErrorMessage(err));
} }
} }