@@ -3631,6 +3631,7 @@ export const createExecutor = <const TPlugins extends readonly AnyPlugin[] = rea
36313631 ? b . isNull ( "tools_synced_at" )
36323632 : b . or ( b . isNull ( "tools_synced_at" ) , b ( "tools_synced_at" , "<" , staleBefore ) ) ,
36333633 } ) ;
3634+ const tasks = [ ] ;
36343635 for ( const connection of connections ) {
36353636 const integrationRow = integrationBySlug . get ( connection . integration ) ;
36363637 if ( ! integrationRow ) continue ;
@@ -3657,24 +3658,29 @@ export const createExecutor = <const TPlugins extends readonly AnyPlugin[] = rea
36573658 syncedAt < cutoff ;
36583659 if ( ! staleMarked && ! configRevised && ! expired ) continue ;
36593660
3660- yield * produceConnectionTools (
3661- integrationRow ,
3662- {
3663- owner : connection . owner as Owner ,
3664- integration : IntegrationSlug . make ( connection . integration ) ,
3665- name : ConnectionName . make ( connection . name ) ,
3666- } ,
3667- "background" ,
3668- ) . pipe (
3669- Effect . catch ( ( ) => Effect . succeed ( [ ] as readonly Tool [ ] ) ) ,
3670- Effect . withSpan ( "executor.tools.sync_stale" , {
3671- attributes : {
3672- "executor.integration" : connection . integration ,
3673- "executor.connection" : connection . name ,
3661+ tasks . push (
3662+ produceConnectionTools (
3663+ integrationRow ,
3664+ {
3665+ owner : connection . owner as Owner ,
3666+ integration : IntegrationSlug . make ( connection . integration ) ,
3667+ name : ConnectionName . make ( connection . name ) ,
36743668 } ,
3675- } ) ,
3669+ "background" ,
3670+ ) . pipe (
3671+ Effect . catch ( ( ) => Effect . succeed ( [ ] as readonly Tool [ ] ) ) ,
3672+ Effect . withSpan ( "executor.tools.sync_stale" , {
3673+ attributes : {
3674+ "executor.integration" : connection . integration ,
3675+ "executor.connection" : connection . name ,
3676+ } ,
3677+ } ) ,
3678+ ) ,
36763679 ) ;
36773680 }
3681+ if ( tasks . length > 0 ) {
3682+ yield * Effect . all ( tasks , { concurrency : 10 } ) ;
3683+ }
36783684 } ) ;
36793685
36803686 const toolsList = ( filter ?: ToolListFilter ) : Effect . Effect < readonly Tool [ ] , StorageFailure > =>
0 commit comments