dart-archive / observe

Support for marking objects as observable, and getting notifications when those objects are mutated
https://pub.dartlang.org/packages/observe
BSD 3-Clause "New" or "Revised" License
13 stars 6 forks source link

[observer] infinite loop in ChangeNotifier #65

Closed DartBot closed 9 years ago

DartBot commented 9 years ago

Issue by vicb Originally opened as dart-lang/sdk#19472


When using an Observable, there is a safeguard in dirtyCheckObservables() to make sure the code does not enter an infinite loop.

There is no such safeguard in the ChangeNotifier and it might lead to an infinite loop:

  var list = new ObservableList();   var depList = new ObservableList();

  list.changes.listen((records) {     depList.add('change');   });

  depList.changes.listen((records) {     list.add('change');   });

Do you think it would be possible to implement such a safeguard for this code ?

DartBot commented 9 years ago

Comment by kasperl


Added Area-Pkg, Pkg-Observe, Triaged labels.

DartBot commented 9 years ago

Comment by jmesserly


Do you think it would be possible to implement such a safeguard for this code ?

doubtful, since there is nothing global to coordinate on. Introducing a global coordination would probably make it difficult to implement ChangeNotifier (it's just an interface) and/or adversely affect performance. I'm open to ideas but it's not clear to me how to fix it.

It is unfortunately like any other infinite loop in Dart, or infinite series of async operations. I find debugging infinite loops in Dartium to be super hard, since debug tools can't reliably cause the code to break, so definitely sympathize on that. I wonder if we could improve the tools or somehow improve this more globally in Dart, perhaps by having a debug Zone that breaks after so many async ops, or makes it easier to set a breakpoint, or something along those lines.


Added PatchesWelcome label.

DartBot commented 9 years ago

Comment by jmesserly


(it's just an interface)

it's actually a mixin ... what I meant by that is: it's intended to be usable as just an interface.

DartBot commented 9 years ago

Comment by sigmundch


Added this to the Later milestone. Removed Priority-Unassigned label. Added Priority-Low label.

DartBot commented 9 years ago

Comment by sigmundch


Added Polymer-P-2 label.

DartBot commented 9 years ago

Comment by sigmundch


Removed this from the Later milestone.

DartBot commented 9 years ago

Comment by sigmundch


Removed Polymer-P-2 label. Added Polymer-Milestone-Later label.

DartBot commented 9 years ago

Comment by sigmundch


Removed Polymer-Milestone-Later label. Added PolymerMilestone-Later label.

DartBot commented 9 years ago

Comment by jmesserly


inclined to say this is not in the cards. but pull requests welcome @­ https://github.com/dart-lang/observe


Added NotPlanned label.