File tree 1 file changed +16
-6
lines changed
1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -236,14 +236,24 @@ export class ComputedNode<T> extends SignalNode<T | ComputedSpecialValues> imple
236
236
this . computing = true ;
237
237
let value : T | ComputedSpecialValues ;
238
238
const prevActiveConsumer = setActiveConsumer ( this ) ;
239
- try {
240
- value = this . computeFn . call ( this . wrapper ) ;
241
- } catch ( error ) {
242
- value = COMPUTED_ERRORED ;
243
- this . error = error ;
239
+ let isUpToDate = false ;
240
+ let iterations = 0 ;
241
+ while ( ! isUpToDate && iterations < 1000 ) {
242
+ try {
243
+ value = this . computeFn . call ( this . wrapper ) ;
244
+ } catch ( error ) {
245
+ value = COMPUTED_ERRORED ;
246
+ this . error = error ;
247
+ }
248
+ this . #removeUnusedProducers( ) ;
249
+ iterations ++ ;
250
+ isUpToDate = this . #areProducersUpToDate( ) ;
244
251
}
245
- this . #removeUnusedProducers( ) ;
246
252
setActiveConsumer ( prevActiveConsumer ) ;
253
+ if ( ! isUpToDate ) {
254
+ value = COMPUTED_ERRORED ;
255
+ this . error = new Error ( 'Could not stabilize the computation.' ) ;
256
+ }
247
257
this . computing = false ;
248
258
this . dirty = false ;
249
259
this . set ( value , false ) ;
You can’t perform that action at this time.
0 commit comments