Skip to content

Commit 4faabf1

Browse files
committed
fix(MonitorScope): don't freeze toTime on the live Monitor scope
Setting `toTime = config.toTime ?? Date.now()/1000` for the live Monitor's `eventsGetScope` froze the upper bound at attach time. Subsequent socket `eventsChanged` pushes triggered `events.get` with that frozen `toTime`, so any event created after attach was filtered out and never reached consumers — the socket fired, the UI never updated. Only include `toTime` when the consumer explicitly configured one; otherwise let the Monitor default to `Number.MAX_VALUE`. The initial paginated `events.get` keeps its `Date.now()` fallback (bounding the backfill is correct; bounding the live listener was the bug). Verified live in hds-webapp: external fetch from outside the app's own MonitorScope now lands in `appService.events` within ~2.5s via the socket push, with no page refresh.
1 parent 3df7e3c commit 4faabf1

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

ts/MonitorScope.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,15 @@ export class MonitorScope {
142142
*/
143143
private async attachLiveMonitor (): Promise<void> {
144144
if (this.stopped) return;
145-
const toTime = this.config.toTime ?? (Date.now() / 1000);
146145
const eventsGetScope: any = {
147146
fromTime: this.config.fromTime,
148-
toTime,
149147
modifiedSince: this.maxModified,
150148
};
149+
// Bound the live scope only if the consumer asked for one. A frozen
150+
// `toTime = now` would exclude every event created after attach time —
151+
// the socket's `eventsChanged` push fires, but the follow-up events.get
152+
// returns nothing and the UI never updates.
153+
if (this.config.toTime != null) eventsGetScope.toTime = this.config.toTime;
151154

152155
this.monitor = new (pryv as any).Monitor(this.connection, eventsGetScope)
153156
.on('event', (event: Event) => {

0 commit comments

Comments
 (0)