Description
When compiling a Solidity contract that imports OpenZeppelin libraries (AccessControl, ReentrancyGuard, Pausable) in the Studio with PVM (Polkadot) target, compilation consistently fails with two different errors depending on server load:
- Timeout:
Compilation timed out after 30s
- Invalid response:
Unexpected token '<', "<!DOCTYPE "... is not valid JSON
The second error indicates the compilation API endpoint is returning an HTML error page (likely a 502/504 gateway timeout) instead of a JSON response.
Steps to Reproduce
- Go to https://relaycode.org/studio
- Connect wallet to AssetHub Westend
- Ensure PVM (Polkadot) compile target is selected
- Paste a contract with OpenZeppelin imports (e.g. a contract inheriting from
AccessControl, ReentrancyGuard, Pausable)
- Click Compile
Expected Behavior
Contract compiles successfully and .bin/.abi outputs are generated.
Actual Behavior
- First attempt: "Compilation timed out after 30s"
- Second attempt:
Unexpected token '<', "<!DOCTYPE "... is not valid JSON — the compile API returns HTML instead of JSON
Environment
- Browser: Chrome (macOS)
- Chain: AssetHub Westend
- Compile target: PVM (Polkadot)
- Solidity version: ^0.8.20
- Contract size: ~340 lines with 3 OpenZeppelin imports
Analysis
The 30s timeout may be insufficient for PVM compilation of contracts with multiple transitive OpenZeppelin dependencies. The JSON parse error on retry suggests the backend may be crashing or the reverse proxy is returning an error page when the compiler process exceeds a resource limit.
Possible causes:
- Compilation timeout is too short for PVM target with OZ dependencies (resolc is slower than solc)
- Backend doesn't handle compilation timeout gracefully — returns HTML error instead of a JSON error response
- The retry hits a cached error state from the previous failed attempt
Suggested Fix
- Increase the PVM compilation timeout (60-90s would be safer for contracts with OZ imports)
- Ensure the compile API always returns JSON, even on internal errors/timeouts
- Add proper error handling for gateway timeouts in the frontend
Description
When compiling a Solidity contract that imports OpenZeppelin libraries (
AccessControl,ReentrancyGuard,Pausable) in the Studio with PVM (Polkadot) target, compilation consistently fails with two different errors depending on server load:Compilation timed out after 30sUnexpected token '<', "<!DOCTYPE "... is not valid JSONThe second error indicates the compilation API endpoint is returning an HTML error page (likely a 502/504 gateway timeout) instead of a JSON response.
Steps to Reproduce
AccessControl,ReentrancyGuard,Pausable)Expected Behavior
Contract compiles successfully and .bin/.abi outputs are generated.
Actual Behavior
Unexpected token '<', "<!DOCTYPE "... is not valid JSON— the compile API returns HTML instead of JSONEnvironment
Analysis
The 30s timeout may be insufficient for PVM compilation of contracts with multiple transitive OpenZeppelin dependencies. The JSON parse error on retry suggests the backend may be crashing or the reverse proxy is returning an error page when the compiler process exceeds a resource limit.
Possible causes:
Suggested Fix