Skip to content

Commit 36ffc51

Browse files
hdshawkw
authored andcommitted
fix(subscriber): correct retain logic (#447)
The current logic present in `IdData::drop_closed` marks an item (task, resource, and async op stats) to be dropped in the case that the item **is** dirty and there **are** watchers: `(dirty && has_watchers)`. This causes a case where if an item is first received and then completes in between the aggregator push cycle, it will be discarded immediately and never sent. This logic has been in place since the concepts of watchers and dirty items was introduced in #77. However since an item that is created and then dropped within a single update cycle isn't likely to be missed in the UI, it may never have been noticed. Instead the logic should be to **retain** an item if **any** of the following is true: * there are watchers and the item is dirty: `(dirty && has_watchers)` * item has been dropped less time than the retention period: `dropped_for <= retention`.
1 parent 132ed4e commit 36ffc51

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

console-subscriber/src/aggregator/id_data.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,18 @@ impl<T: Unsent> IdData<T> {
104104
if let Some(dropped_at) = stats.dropped_at() {
105105
let dropped_for = now.checked_duration_since(dropped_at).unwrap_or_default();
106106
let dirty = stats.is_unsent();
107-
let should_drop =
107+
let should_retain =
108108
// if there are any clients watching, retain all dirty tasks regardless of age
109109
(dirty && has_watchers)
110-
|| dropped_for > retention;
110+
|| dropped_for <= retention;
111111
tracing::trace!(
112112
stats.id = ?id,
113113
stats.dropped_at = ?dropped_at,
114114
stats.dropped_for = ?dropped_for,
115115
stats.dirty = dirty,
116-
should_drop,
116+
should_retain,
117117
);
118-
return !should_drop;
118+
return should_retain;
119119
}
120120

121121
true

0 commit comments

Comments
 (0)