Skip to content

Fix PVM compilation timeout and handle non-JSON error responses#39

Merged
itsyogesh merged 2 commits intomasterfrom
fix/pvm-compile-timeout
Mar 21, 2026
Merged

Fix PVM compilation timeout and handle non-JSON error responses#39
itsyogesh merged 2 commits intomasterfrom
fix/pvm-compile-timeout

Conversation

@itsyogesh
Copy link
Copy Markdown
Owner

Summary

Fixes #38 — PVM compilation with OpenZeppelin imports times out on production.

Root cause: The worker timeout was 30s for both EVM and PVM. The resolc compiler (PVM) is significantly slower than solc (EVM), especially with transitive OpenZeppelin dependencies. Large contracts consistently exceed 30s.

Secondary issue: When the compilation times out and Vercel returns a 502/504 gateway timeout (HTML), the client crashes with Unexpected token '<' because it calls res.json() on an HTML response.

Changes

  • PVM worker timeout: 30s → 90s — resolc needs more time for OZ-heavy contracts
  • EVM worker timeout stays 30s — solc is fast, no change needed
  • Vercel maxDuration: 60s → 120s — headroom for import resolution + PVM compilation
  • Safe JSON parsing in both compileSolidity() and compileSoliditySources() — catches HTML error responses and returns a clear error message instead of crashing

Test plan

  • Simple contract (no imports) compiles in PVM mode on production
  • Contract with OZ imports compiles in PVM mode without timeout
  • If compilation does time out, error message is clear (not Unexpected token '<')
  • EVM compilation still works and is fast
  • yarn test passes
  • yarn build passes

- Increase PVM worker timeout from 30s to 90s (resolc is significantly
  slower than solc, especially with OpenZeppelin transitive deps)
- Keep EVM worker timeout at 30s (solc is fast)
- Increase Vercel maxDuration from 60s to 120s for headroom
- Add safe JSON parsing in both compileSolidity and
  compileSoliditySources — catches HTML 502/504 gateway timeout
  responses and returns a user-friendly error instead of crashing

Fixes #38
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
relaycode Ready Ready Preview, Comment Mar 21, 2026 5:53pm

Request Review

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 21, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 0% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.42%. Comparing base (ef36a44) to head (cd5ec2b).

Files with missing lines Patch % Lines
lib/compile-client.ts 0.00% 35 Missing ⚠️
lib/import-resolver.ts 0.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #39      +/-   ##
==========================================
- Coverage   50.49%   50.42%   -0.08%     
==========================================
  Files         178      178              
  Lines       22233    22266      +33     
  Branches     1236     1236              
==========================================
  Hits        11227    11227              
- Misses      10958    10991      +33     
  Partials       48       48              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Reduce import resolution budget from 30s to 20s and PVM worker timeout
from 90s to 80s. Worst case is now 20s + 80s = 100s, leaving 20s of
headroom within the 120s maxDuration for cold start, request parsing,
and response serialization.
@itsyogesh itsyogesh merged commit d525f21 into master Mar 21, 2026
5 checks passed
@itsyogesh itsyogesh deleted the fix/pvm-compile-timeout branch March 21, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Studio: PVM compilation fails for contracts with OpenZeppelin imports

2 participants