Skip to content

Commit

Permalink
Fix remote clock subscription (#6919)
Browse files Browse the repository at this point in the history
* If there are no listeners for this clock then don't bother subscribing after getting the domain object details

* Comment explaining the fix
  • Loading branch information
shefalijoshi authored Aug 14, 2023
1 parent 57743e5 commit c53073b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/plugins/remoteClock/RemoteClock.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ export default class RemoteClock extends DefaultClock {
this.openmct.objects
.get(this.identifier)
.then((domainObject) => {
// The start method is called when at least one listener registers with the clock.
// When the clock is changed, listeners are unregistered from the clock and the stop method is called.
// Sometimes, the objects.get call above does not resolve before the stop method is called.
// So when we proceed with the clock subscription below, we first need to ensure that there is at least one listener for our clock.
if (this.eventNames().length === 0) {
return;
}
this.openmct.time.on('timeSystem', this._timeSystemChange);
this.timeTelemetryObject = domainObject;
this.metadata = this.openmct.telemetry.getMetadata(domainObject);
Expand Down

0 comments on commit c53073b

Please sign in to comment.