@@ -1252,10 +1252,20 @@ export class Pregel<
12521252 throw new InvalidUpdateError ( `Cannot copy a non-existent checkpoint` ) ;
12531253 }
12541254
1255+ const isCopyWithUpdates = (
1256+ values : unknown
1257+ ) : values is [ values : unknown , asNode : string ] [ ] => {
1258+ if ( ! Array . isArray ( values ) ) return false ;
1259+ if ( values . length === 0 ) return false ;
1260+ return values . every ( ( v ) => Array . isArray ( v ) && v . length === 2 ) ;
1261+ } ;
1262+
12551263 const nextCheckpoint = createCheckpoint ( checkpoint , undefined , step ) ;
12561264 const nextConfig = await checkpointer . put (
12571265 saved . parentConfig ??
1258- patchConfigurable ( saved . config , { checkpoint_id : undefined } ) ,
1266+ ( isCopyWithUpdates ( values )
1267+ ? patchConfigurable ( saved . config , { checkpoint_id : undefined } )
1268+ : saved . config ) ,
12591269 nextCheckpoint ,
12601270 {
12611271 source : "fork" ,
@@ -1266,14 +1276,6 @@ export class Pregel<
12661276 { }
12671277 ) ;
12681278
1269- const isCopyWithUpdates = (
1270- values : unknown
1271- ) : values is [ values : unknown , asNode : string ] [ ] => {
1272- if ( ! Array . isArray ( values ) ) return false ;
1273- if ( values . length === 0 ) return false ;
1274- return values . every ( ( v ) => Array . isArray ( v ) && v . length === 2 ) ;
1275- } ;
1276-
12771279 // We want to both clone a checkpoint and update state in one go.
12781280 // Reuse the same task ID if possible.
12791281 if ( isCopyWithUpdates ( values ) ) {
0 commit comments