@@ -5,10 +5,11 @@ import { resolveAllImports, resolveAllImportsSources } from "@/lib/import-resolv
55import { checkRateLimit , getRateLimitReset } from "@/lib/rate-limiter" ;
66
77export const runtime = "nodejs" ;
8- export const maxDuration = 60 ;
8+ export const maxDuration = 120 ;
99
1010const MAX_BODY_SIZE = 512000 ; // 500KB
11- const WORKER_TIMEOUT_MS = 30_000 ;
11+ const WORKER_TIMEOUT_EVM_MS = 30_000 ;
12+ const WORKER_TIMEOUT_PVM_MS = 80_000 ; // resolc is slower; 20s resolver + 80s compile = 100s < 120s maxDuration
1213
1314interface CompileRequest {
1415 source ?: string ;
@@ -28,17 +29,18 @@ interface CompileResponse {
2829function compileInWorker (
2930 input : string ,
3031 mode : string ,
31- timeoutMs = WORKER_TIMEOUT_MS
32+ timeoutMs ?: number
3233) : Promise < any > {
34+ const timeout = timeoutMs ?? ( mode === "pvm" ? WORKER_TIMEOUT_PVM_MS : WORKER_TIMEOUT_EVM_MS ) ;
3335 return new Promise ( ( resolve , reject ) => {
3436 const worker = new Worker ( COMPILE_WORKER_CODE , {
3537 eval : true ,
3638 workerData : { mode, input } ,
3739 } ) ;
3840 const timer = setTimeout ( ( ) => {
3941 worker . terminate ( ) ;
40- reject ( new Error ( " Compilation timed out after 30s" ) ) ;
41- } , timeoutMs ) ;
42+ reject ( new Error ( ` Compilation timed out after ${ Math . round ( timeout / 1000 ) } s` ) ) ;
43+ } , timeout ) ;
4244
4345 worker . on ( "message" , ( msg ) => {
4446 clearTimeout ( timer ) ;
0 commit comments