From 1bfb577834d0b15546aa5a08968fd2a7698a15fb Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Wed, 19 Jul 2023 10:50:10 +0100 Subject: [PATCH] Add context to error logged when anchoring fails If the transcript fails to load in the video player app, it will reject the `contentReady` promise that the client waits on. The client would then cause the error to be thrown from `Guest.anchor`. Catch this error and add context to indicate what has gone wrong. --- src/annotator/guest.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/annotator/guest.ts b/src/annotator/guest.ts index 91b2e9c1e47..a46201d9319 100644 --- a/src/annotator/guest.ts +++ b/src/annotator/guest.ts @@ -566,8 +566,16 @@ export class Guest extends TinyEmitter implements Annotator, Destroyable { this._sidebarRPC.on('deleteAnnotation', (tag: string) => this.detach(tag)); - this._sidebarRPC.on('loadAnnotations', (annotations: AnnotationData[]) => - annotations.forEach(annotation => this.anchor(annotation)) + this._sidebarRPC.on( + 'loadAnnotations', + async (annotations: AnnotationData[]) => { + try { + await Promise.all(annotations.map(ann => this.anchor(ann))); + } catch (e) { + /* istanbul ignore next */ + console.warn('Failed to anchor annotations:', e); + } + } ); this._sidebarRPC.on('showContentInfo', (info: ContentInfoConfig) =>