@@ -120,10 +120,9 @@ export class WorkloadServer extends EventEmitter<WorkloadServerEvents> {
120120 // hours later after a checkpoint/restore cycle. Using a capped map avoids unbounded
121121 // growth while keeping recent contexts available. Oldest entries are evicted first.
122122 private static readonly MAX_TRACE_CONTEXTS = 10_000 ;
123- private static readonly SNAPSHOT_CONCURRENCY = 10 ;
124123 private readonly runTraceContexts = new Map < string , RunTraceContext > ( ) ;
125124 private readonly snapshotDelayWheel ?: TimerWheel < DelayedSnapshot > ;
126- private readonly snapshotLimit = pLimit ( WorkloadServer . SNAPSHOT_CONCURRENCY ) ;
125+ private readonly snapshotLimit ?: ReturnType < typeof pLimit > ;
127126
128127 constructor ( opts : WorkloadServerOptions ) {
129128 super ( ) ;
@@ -137,10 +136,12 @@ export class WorkloadServer extends EventEmitter<WorkloadServerEvents> {
137136 this . tracing = opts . tracing ;
138137
139138 if ( this . computeManager ?. snapshotsEnabled ) {
139+ const snapshotLimit = pLimit ( this . computeManager . snapshotDispatchLimit ) ;
140+ this . snapshotLimit = snapshotLimit ;
140141 this . snapshotDelayWheel = new TimerWheel < DelayedSnapshot > ( {
141142 delayMs : this . computeManager . snapshotDelayMs ,
142143 onExpire : ( item ) => {
143- this . snapshotLimit ( ( ) => this . dispatchComputeSnapshot ( item . data ) ) . catch ( ( error ) => {
144+ snapshotLimit ( ( ) => this . dispatchComputeSnapshot ( item . data ) ) . catch ( ( error ) => {
144145 this . logger . error ( "Compute snapshot dispatch failed" , {
145146 runId : item . data . runFriendlyId ,
146147 runnerId : item . data . runnerId ,
0 commit comments