Nomic Foundation / Hardhat
Merged upstreamTestingMerged Jul 14, 2026

Stream-parse Solidity test build outputs

Fixed Hardhat Solidity tests so very large build-info outputs can be parsed without materializing the entire JSON payload as one Node string.

NomicFoundation/hardhat · #8414

Problem

The Solidity test runner decoded selected build-info output bytes into a full string before JSON parsing in inline-config and EIP-712 collectors. Projects with outputs larger than V8's maximum string length could throw ERR_STRING_TOO_LONG and abort before any Solidity test started.

Approach

Added parseJsonBytes with a normal JSON.parse fast path and a streaming parser fallback for payloads too large for one string. Reused the streaming parser in file JSON reads, converted the Solidity test collectors to async parsing, awaited them from the task action, and wrapped corrupted build-info output failures in a dedicated HardhatError.

Impact and scope

  • Allows Solidity tests to run in large real-world projects whose build-info outputs exceed Node's maximum string size.
  • Keeps existing byte-level skip checks and the faster JSON.parse path for normal-sized outputs.
  • Improves diagnostics for corrupted build-info outputs instead of surfacing low-level JSON parser failures.

Validation

  • Added hardhat-utils coverage for parseJsonBytes and simulated over-limit stream fallback.
  • Added inline-config and EIP-712 regression coverage for large-output stream fallback and parse-error handling.
  • PR validation included targeted lint and test commands for hardhat-utils, inline config, EIP-712, and Solidity test task integration.
  • Follow-up maintainer comment confirms the fix shipped in hardhat@3.10.0.