diff --git a/src/lib/viewers/BaseViewer.js b/src/lib/viewers/BaseViewer.js index 52122414a..3e22886c0 100644 --- a/src/lib/viewers/BaseViewer.js +++ b/src/lib/viewers/BaseViewer.js @@ -254,8 +254,12 @@ class BaseViewer extends EventEmitter { // Destroy the annotator if (this.annotator && typeof this.annotator.destroy === 'function') { - this.annotator.removeAllListeners(); - this.annotator.destroy(); + try { + this.annotator.removeAllListeners(); + this.annotator.destroy(); + } catch (error) { + // No-op, as annotator was likely never initialized in the first place + } } this.destroyed = true;