diff --git a/src/sql/base/browser/lifecycle.ts b/src/sql/base/browser/lifecycle.ts index e3aef092b5..4b193252c3 100644 --- a/src/sql/base/browser/lifecycle.ts +++ b/src/sql/base/browser/lifecycle.ts @@ -17,7 +17,10 @@ export function subscriptionToDisposable(sub: Subscription): IDisposable { } export class AngularDisposable extends Disposable implements OnDestroy { + public isDisposed = false; + ngOnDestroy() { this.dispose(); + this.isDisposed = true; } } diff --git a/src/sql/workbench/browser/modelComponents/modelComponentWrapper.component.ts b/src/sql/workbench/browser/modelComponents/modelComponentWrapper.component.ts index ade7069f54..a58dd4b43f 100644 --- a/src/sql/workbench/browser/modelComponents/modelComponentWrapper.component.ts +++ b/src/sql/workbench/browser/modelComponents/modelComponentWrapper.component.ts @@ -110,7 +110,7 @@ export class ModelComponentWrapper extends AngularDisposable implements AfterVie let selector = componentRegistry.getCtorFromId(this.descriptor.type); 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; } @@ -128,7 +128,13 @@ export class ModelComponentWrapper extends AngularDisposable implements AfterVie this._componentInstance.modelStore = this.modelStore; this._changeref.detectChanges(); } 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; } let el = componentRef.location.nativeElement; diff --git a/src/sql/workbench/services/notebook/browser/models/notebookModel.ts b/src/sql/workbench/services/notebook/browser/models/notebookModel.ts index f4da200494..904773718e 100644 --- a/src/sql/workbench/services/notebook/browser/models/notebookModel.ts +++ b/src/sql/workbench/services/notebook/browser/models/notebookModel.ts @@ -1118,7 +1118,7 @@ export class NotebookModel extends Disposable implements INotebookModel { } await this.shutdownActiveSession(); } 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)); } }