@@ -52,23 +52,24 @@ export interface IsolatedVMError {
5252 lineContent ?: string
5353}
5454
55- const POOL_SIZE = Number . parseInt ( env . IVM_POOL_SIZE )
56- const MAX_CONCURRENT = Number . parseInt ( env . IVM_MAX_CONCURRENT )
57- const MAX_PER_WORKER = Number . parseInt ( env . IVM_MAX_PER_WORKER )
58- const WORKER_IDLE_TIMEOUT_MS = Number . parseInt ( env . IVM_WORKER_IDLE_TIMEOUT_MS )
59- const QUEUE_TIMEOUT_MS = Number . parseInt ( env . IVM_QUEUE_TIMEOUT_MS )
60- const MAX_QUEUE_SIZE = Number . parseInt ( env . IVM_MAX_QUEUE_SIZE )
61- const MAX_FETCH_RESPONSE_BYTES = Number . parseInt ( env . IVM_MAX_FETCH_RESPONSE_BYTES )
62- const MAX_FETCH_RESPONSE_CHARS = Number . parseInt ( env . IVM_MAX_FETCH_RESPONSE_CHARS )
63- const MAX_FETCH_URL_LENGTH = Number . parseInt ( env . IVM_MAX_FETCH_URL_LENGTH )
64- const MAX_FETCH_OPTIONS_JSON_CHARS = Number . parseInt ( env . IVM_MAX_FETCH_OPTIONS_JSON_CHARS )
65- const MAX_ACTIVE_PER_OWNER = Number . parseInt ( env . IVM_MAX_ACTIVE_PER_OWNER )
66- const MAX_QUEUED_PER_OWNER = Number . parseInt ( env . IVM_MAX_QUEUED_PER_OWNER )
67- const MAX_OWNER_WEIGHT = Number . parseInt ( env . IVM_MAX_OWNER_WEIGHT )
68- const DISTRIBUTED_MAX_INFLIGHT_PER_OWNER = Number . parseInt (
69- env . IVM_DISTRIBUTED_MAX_INFLIGHT_PER_OWNER
70- )
71- const DISTRIBUTED_LEASE_MIN_TTL_MS = Number . parseInt ( env . IVM_DISTRIBUTED_LEASE_MIN_TTL_MS )
55+ const POOL_SIZE = Number . parseInt ( env . IVM_POOL_SIZE ) || 4
56+ const MAX_CONCURRENT = Number . parseInt ( env . IVM_MAX_CONCURRENT ) || 10000
57+ const MAX_PER_WORKER = Number . parseInt ( env . IVM_MAX_PER_WORKER ) || 2500
58+ const WORKER_IDLE_TIMEOUT_MS = Number . parseInt ( env . IVM_WORKER_IDLE_TIMEOUT_MS ) || 60000
59+ const QUEUE_TIMEOUT_MS = Number . parseInt ( env . IVM_QUEUE_TIMEOUT_MS ) || 300000
60+ const MAX_QUEUE_SIZE = Number . parseInt ( env . IVM_MAX_QUEUE_SIZE ) || 10000
61+ const MAX_FETCH_RESPONSE_BYTES = Number . parseInt ( env . IVM_MAX_FETCH_RESPONSE_BYTES ) || 8_388_608
62+ const MAX_FETCH_RESPONSE_CHARS = Number . parseInt ( env . IVM_MAX_FETCH_RESPONSE_CHARS ) || 4_000_000
63+ const MAX_FETCH_URL_LENGTH = Number . parseInt ( env . IVM_MAX_FETCH_URL_LENGTH ) || 8192
64+ const MAX_FETCH_OPTIONS_JSON_CHARS =
65+ Number . parseInt ( env . IVM_MAX_FETCH_OPTIONS_JSON_CHARS ) || 262_144
66+ const MAX_ACTIVE_PER_OWNER = Number . parseInt ( env . IVM_MAX_ACTIVE_PER_OWNER ) || 200
67+ const MAX_QUEUED_PER_OWNER = Number . parseInt ( env . IVM_MAX_QUEUED_PER_OWNER ) || 2000
68+ const MAX_OWNER_WEIGHT = Number . parseInt ( env . IVM_MAX_OWNER_WEIGHT ) || 5
69+ const DISTRIBUTED_MAX_INFLIGHT_PER_OWNER =
70+ Number . parseInt ( env . IVM_DISTRIBUTED_MAX_INFLIGHT_PER_OWNER ) ||
71+ MAX_ACTIVE_PER_OWNER + MAX_QUEUED_PER_OWNER
72+ const DISTRIBUTED_LEASE_MIN_TTL_MS = Number . parseInt ( env . IVM_DISTRIBUTED_LEASE_MIN_TTL_MS ) || 120000
7273const DISTRIBUTED_KEY_PREFIX = 'ivm:fair:v1:owner'
7374const QUEUE_RETRY_DELAY_MS = 1000
7475const DISTRIBUTED_LEASE_GRACE_MS = 30000
@@ -611,7 +612,7 @@ function cleanupWorker(workerId: number) {
611612 pending . resolve ( {
612613 result : null ,
613614 stdout : '' ,
614- error : { message : 'Worker process exited unexpectedly' , name : 'WorkerError ' } ,
615+ error : { message : 'Code execution failed unexpectedly. Please try again. ' , name : 'Error ' } ,
615616 } )
616617 workerInfo . pendingExecutions . delete ( id )
617618 }
@@ -848,7 +849,7 @@ function dispatchToWorker(
848849 resolve ( {
849850 result : null ,
850851 stdout : '' ,
851- error : { message : 'Failed to send execution request to worker ' , name : 'WorkerError ' } ,
852+ error : { message : 'Code execution failed to start. Please try again. ' , name : 'Error ' } ,
852853 } )
853854 resetWorkerIdleTimeout ( workerInfo . id )
854855 // Defer to break synchronous recursion: drainQueue → dispatchToWorker → catch → drainQueue
@@ -866,8 +867,8 @@ function enqueueExecution(
866867 result : null ,
867868 stdout : '' ,
868869 error : {
869- message : `Execution queue is full ( ${ MAX_QUEUE_SIZE } ) . Please retry later.` ,
870- name : 'QueueFullError ' ,
870+ message : 'Code execution is at capacity . Please try again in a moment.' ,
871+ name : 'Error ' ,
871872 } ,
872873 } )
873874 return
@@ -877,8 +878,9 @@ function enqueueExecution(
877878 result : null ,
878879 stdout : '' ,
879880 error : {
880- message : `Owner queue limit reached (${ MAX_QUEUED_PER_OWNER } ). Please retry later.` ,
881- name : 'OwnerQueueLimitError' ,
881+ message :
882+ 'Too many concurrent code executions. Please wait for some to complete before running more.' ,
883+ name : 'Error' ,
882884 } ,
883885 } )
884886 return
@@ -892,8 +894,8 @@ function enqueueExecution(
892894 result : null ,
893895 stdout : '' ,
894896 error : {
895- message : `Execution queued too long ( ${ QUEUE_TIMEOUT_MS } ms). All workers are busy.` ,
896- name : 'QueueTimeoutError ' ,
897+ message : 'Code execution timed out waiting for an available worker. Please try again.' ,
898+ name : 'Error ' ,
897899 } ,
898900 } )
899901 } , QUEUE_TIMEOUT_MS )
@@ -973,8 +975,9 @@ export async function executeInIsolatedVM(
973975 result : null ,
974976 stdout : '' ,
975977 error : {
976- message : `Owner in-flight limit reached (${ DISTRIBUTED_MAX_INFLIGHT_PER_OWNER } ). Please retry later.` ,
977- name : 'OwnerInFlightLimitError' ,
978+ message :
979+ 'Too many concurrent code executions. Please wait for some to complete before running more.' ,
980+ name : 'Error' ,
978981 } ,
979982 }
980983 }
@@ -983,8 +986,8 @@ export async function executeInIsolatedVM(
983986 result : null ,
984987 stdout : '' ,
985988 error : {
986- message : 'Distributed fairness is temporarily unavailable. Please retry .' ,
987- name : 'DistributedFairnessUnavailableError ' ,
989+ message : 'Code execution is temporarily unavailable. Please try again in a moment .' ,
990+ name : 'Error ' ,
988991 } ,
989992 }
990993 }
0 commit comments