Skip to content

Commit

Permalink
fix(MesosStateStore): adjust stream data handling
Browse files Browse the repository at this point in the history
Use `Promise.resolve().then()` to trigger the stream subscription asynchronously on the same macrotask (by using a microtask). Events emitted by the strean, trigger `onStreamData` which is used to emit an event (using EventEmitter) called `MESOS_STATE_CHANGE`. This change will mitigate issues in which errors in view components lead to stale data because the error propagation broke the stream.

N.B. `EventEmitter` is synchronous meaning that every delay in an event handler effects the `emit` execution time and errors propagate up to the `emit` call which sometimes leads to undesireable behavior.

Closes DCOS-21784
  • Loading branch information
Orlando Hohmeier authored and Fabs committed Mar 26, 2018
1 parent 912b7da commit 806e4db
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/js/stores/MesosStateStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class MesosStateStore extends GetSetBaseStore {
this.on(eventName, callback);

if (this.shouldSubscribe()) {
this.subscribe();
Promise.resolve().then(() => this.subscribe());
}
}

Expand Down Expand Up @@ -99,7 +99,8 @@ class MesosStateStore extends GetSetBaseStore {
// refresh limits to the UI. They are:
//
// MOST once every (Config.getRefreshRate() * 0.5) ms. due to debounceTime.
// LEAST once every tick of Config.getRefreshRate() ms in Observable.interval
// LEAST once every tick of Config.getRefreshRate() ms in
// Observable.interval
//
// TODO: https://jira.mesosphere.com/browse/DCOS-18277
this.stream = waitStream
Expand Down

0 comments on commit 806e4db

Please sign in to comment.