@@ -187,7 +187,10 @@ export class Configraph<
187
187
188
188
this . initEntitiesDag ( ) ;
189
189
190
- const postProcessFns : Array < ( ) => void > = [ ] ;
190
+ const postProcessFns : Array < {
191
+ node : ConfigraphNode ,
192
+ fns : Array < ( ) => void > ,
193
+ } > = [ ] ;
191
194
for ( const entity of this . sortedEntities ) {
192
195
const ancestorIds = entity . ancestorIds ;
193
196
@@ -315,7 +318,7 @@ export class Configraph<
315
318
// calls process on each item's resolver, and collects "post-processing" functions to call if necessary
316
319
try {
317
320
const nodePostProcessFns = node . valueResolver ?. process ( node ) ;
318
- postProcessFns . push ( ... nodePostProcessFns || [ ] ) ;
321
+ postProcessFns . push ( { node , fns : nodePostProcessFns || [ ] } ) ;
319
322
// TODO: handle errors - attach as schema errors to resolver / node?
320
323
} catch ( err ) {
321
324
if ( err instanceof SchemaError ) {
@@ -331,8 +334,18 @@ export class Configraph<
331
334
332
335
// after the entire graph of config nodes have been processed, we'll call post-processing functions
333
336
// this is needed for `collect()` where we need child entities and their nodes to be initialized
334
- postProcessFns . forEach ( ( postProcessFn ) => {
335
- postProcessFn ( ) ;
337
+ postProcessFns . forEach ( ( { node, fns } ) => {
338
+ fns . forEach ( ( fn ) => {
339
+ try {
340
+ fn ( ) ;
341
+ } catch ( err ) {
342
+ if ( err instanceof SchemaError ) {
343
+ node . schemaErrors . push ( err ) ;
344
+ } else {
345
+ node . schemaErrors . push ( new SchemaError ( err as SchemaError ) ) ;
346
+ }
347
+ }
348
+ } ) ;
336
349
} ) ;
337
350
338
351
// add declared dependencies to the node graph
@@ -361,10 +374,12 @@ export class Configraph<
361
374
const node = this . nodesByFullPath [ nodeId ] ;
362
375
// currently this resolve fn will trigger resolve on nested items
363
376
const nodeWasResolved = node . isResolved ;
377
+ const nodeWasFullyResolved = node . isFullyResolved ;
364
378
await node . resolve ( ) ;
365
379
// for objects, the node first gets "resolved" but not "fully resolved" (where child values rolled back up)
366
- // but this is still considered progress so we track it
380
+ // so we make progress (and therefore should continue) if a node transitions to resolved or fully resolved
367
381
if ( ! nodeWasResolved && node . isResolved ) resolvedCount ++ ;
382
+ else if ( ! nodeWasFullyResolved && node . isFullyResolved ) resolvedCount ++ ;
368
383
if ( ! node . isFullyResolved ) {
369
384
nextBatchNodeIds . push ( nodeId ) ;
370
385
}
0 commit comments