Skip to content

Commit

Permalink
fix(platform): propagate topic subscription errors in context service
Browse files Browse the repository at this point in the history
The uncaught errors in the context service made the unit tests fail from
time to time without apparent reason.
  • Loading branch information
mofogasy authored and danielwiehl committed Feb 22, 2021
1 parent 8ae8595 commit 08bbaf7
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ export class ContextService implements PreDestroy {
.subscribe(observer);

// Send the request.
Promise.all([whenSubscribedToReplyTopic(replyTo), this._whenContextTreeChangeListenerInstalled]).then(() => {
window.parent.postMessage(contextValueLookupRequest, '*');
});
Promise.all([whenSubscribedToReplyTopic(replyTo), this._whenContextTreeChangeListenerInstalled])
.then(() => window.parent.postMessage(contextValueLookupRequest, '*'))
.catch(error => observer.error(error));

return (): void => unsubscribe$.next();
});
Expand All @@ -214,9 +214,9 @@ export class ContextService implements PreDestroy {
.subscribe(observer);

// Send the request.
Promise.all([whenSubscribedToReplyTopic(replyTo), this._whenContextTreeChangeListenerInstalled]).then(() => {
window.parent.postMessage(contextNamesLookupRequest, '*');
});
Promise.all([whenSubscribedToReplyTopic(replyTo), this._whenContextTreeChangeListenerInstalled])
.then(() => window.parent.postMessage(contextNamesLookupRequest, '*'))
.catch(error => observer.error(error));
return (): void => unsubscribe$.next();
});
}
Expand All @@ -230,7 +230,7 @@ export class ContextService implements PreDestroy {
const replyTo = UUID.randomUUID();
const contextObserveRequest = Contexts.newContextTreeObserveRequest(replyTo);

return new Promise<void>(resolve => {
return new Promise<void>((resolve, reject) => {
// Receive change notifications.
Beans.get(MessageClient).observe$<Contexts.ContextTreeChangeEvent | Contexts.RootContextSubscribeEventType>(replyTo)
.pipe(
Expand All @@ -244,10 +244,12 @@ export class ContextService implements PreDestroy {
else {
listener(event);
}
});
}, error => reject(error));

// Send the observe request.
whenSubscribedToReplyTopic(replyTo).then(() => window.parent.postMessage(contextObserveRequest, '*'));
whenSubscribedToReplyTopic(replyTo)
.then(() => window.parent.postMessage(contextObserveRequest, '*'))
.catch(error => reject(error));
});
}

Expand Down

0 comments on commit 08bbaf7

Please sign in to comment.