Skip to content

Commit ef36a44

Browse files
committed
Revert "Fix PVM compilation timeout and handle non-JSON error responses"
This reverts commit 8a6e74b.
1 parent 8a6e74b commit ef36a44

2 files changed

Lines changed: 7 additions & 42 deletions

File tree

app/api/compile/route.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ import { resolveAllImports, resolveAllImportsSources } from "@/lib/import-resolv
55
import { checkRateLimit, getRateLimitReset } from "@/lib/rate-limiter";
66

77
export const runtime = "nodejs";
8-
export const maxDuration = 120;
8+
export const maxDuration = 60;
99

1010
const MAX_BODY_SIZE = 512000; // 500KB
11-
const WORKER_TIMEOUT_EVM_MS = 30_000;
12-
const WORKER_TIMEOUT_PVM_MS = 90_000; // resolc is significantly slower than solc
11+
const WORKER_TIMEOUT_MS = 30_000;
1312

1413
interface CompileRequest {
1514
source?: string;
@@ -29,18 +28,17 @@ interface CompileResponse {
2928
function compileInWorker(
3029
input: string,
3130
mode: string,
32-
timeoutMs?: number
31+
timeoutMs = WORKER_TIMEOUT_MS
3332
): Promise<any> {
34-
const timeout = timeoutMs ?? (mode === "pvm" ? WORKER_TIMEOUT_PVM_MS : WORKER_TIMEOUT_EVM_MS);
3533
return new Promise((resolve, reject) => {
3634
const worker = new Worker(COMPILE_WORKER_CODE, {
3735
eval: true,
3836
workerData: { mode, input },
3937
});
4038
const timer = setTimeout(() => {
4139
worker.terminate();
42-
reject(new Error(`Compilation timed out after ${Math.round(timeout / 1000)}s`));
43-
}, timeout);
40+
reject(new Error("Compilation timed out after 30s"));
41+
}, timeoutMs);
4442

4543
worker.on("message", (msg) => {
4644
clearTimeout(timer);

lib/compile-client.ts

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,7 @@ export async function compileSolidity(
2222
body: JSON.stringify({ source, mode }),
2323
});
2424

25-
let data: any;
26-
try {
27-
data = await res.json();
28-
} catch {
29-
// Server returned non-JSON (e.g., HTML 502/504 gateway timeout)
30-
return {
31-
success: false,
32-
contracts: null,
33-
contractNames: [],
34-
errors: [
35-
{
36-
message: `Server error (HTTP ${res.status}). PVM compilation may need more time — try again or use a simpler contract.`,
37-
severity: "error",
38-
},
39-
],
40-
warnings: [],
41-
};
42-
}
25+
const data = await res.json();
4326

4427
if (!res.ok) {
4528
return {
@@ -108,23 +91,7 @@ export async function compileSoliditySources(
10891
body,
10992
});
11093

111-
let data: any;
112-
try {
113-
data = await res.json();
114-
} catch {
115-
return {
116-
success: false,
117-
contracts: null,
118-
contractNames: [],
119-
errors: [
120-
{
121-
message: `Server error (HTTP ${res.status}). PVM compilation may need more time — try again or use a simpler contract.`,
122-
severity: "error",
123-
},
124-
],
125-
warnings: [],
126-
};
127-
}
94+
const data = await res.json();
12895

12996
if (!res.ok) {
13097
return {

0 commit comments

Comments
 (0)