Skip to content

Studio: PVM compilation fails for contracts with OpenZeppelin imports #38

@itsyogesh

Description

@itsyogesh

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:

  1. Timeout: Compilation timed out after 30s
  2. 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

  1. Go to https://relaycode.org/studio
  2. Connect wallet to AssetHub Westend
  3. Ensure PVM (Polkadot) compile target is selected
  4. Paste a contract with OpenZeppelin imports (e.g. a contract inheriting from AccessControl, ReentrancyGuard, Pausable)
  5. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions