Version of Hardhat
3.5.1 and 3.6.0
What happened?
The Solidity test runner reads each build-info *.output.json into a single Node string via bytesToUtf8String + JSON.parse in two places, and both crash when the output is larger than V8's String::kMaxLength (~512 MiB, 0x1fffffe8). The whole test run aborts before a single test is started.
The triggers are fast byte scans, so the work behind the gate is invisible to users:
- Inline-config collector (
solidity-test/inline-config/index.ts:152-158, in collectRawOverrides) — runs whenever forge-config: or hardhat-config: bytes are present in the build info.
- EIP-712 type collector (
solidity-test/eip712/index.ts:57-66, in collectEip712CanonicalTypes) — runs whenever test.solidity.eip712Types.include is set and the build info contains struct (which is true for nearly every real Solidity project).
Stack traces
Call site 1:
RangeError: Cannot create a string longer than 0x1fffffe8 characters
at TextDecoder.decode (node:internal/encoding:447:16)
at bytesToUtf8String (.../hardhat-utils/src/bytes.ts:59:28)
at collectRawOverrides (.../solidity-test/inline-config/index.ts:157:7)
at getTestFunctionOverrides (.../solidity-test/inline-config/index.ts:55:27)
at runSolidityTests (.../solidity-test/task-action.ts:234:33)
code: 'ERR_STRING_TOO_LONG'
Call site 2 (after patching the first):
RangeError: Cannot create a string longer than 0x1fffffe8 characters
at TextDecoder.decode (node:internal/encoding:447:16)
at bytesToUtf8String (.../hardhat-utils/src/bytes.ts:59:28)
at collectEip712CanonicalTypes (.../solidity-test/eip712/index.ts:65:21)
code: 'ERR_STRING_TOO_LONG'
Minimal reproduction steps
Real project
git clone https://github.com/aave/aave-v4.git
cd aave-v4 && git checkout hh3-migration-v2 # @ ed2ab8d
yarn install --ignore-scripts
npx hardhat compile # succeeds — produces a 698 MiB build-info output
npx hardhat test solidity # crashes with ERR_STRING_TOO_LONG
Expected vs actual
|
Expected |
Actual |
npx hardhat test solidity on a project with a >512 MiB build-info output |
Inline-config / EIP-712 metadata extracted; tests run |
ERR_STRING_TOO_LONG thrown from collectRawOverrides or collectEip712CanonicalTypes; whole run aborts before any test starts |
Environment
- Hardhat: reproduces on
3.5.1 and 3.6.0 (latest at the time of writing)
- EDR:
@nomicfoundation/edr@0.12.0-next.33 (unchanged across both Hardhat versions)
- Node.js:
v22.x
- OS: Linux 6.10
- Repro project's build-info output:
731_669_005 bytes (~698 MiB) for the default profile
Layer
Pure Hardhat (test-runner plugin). Failure happens entirely inside the solidity-test task-action before EDR is invoked.
Search terms
No response
Version of Hardhat
3.5.1 and 3.6.0
What happened?
The Solidity test runner reads each build-info
*.output.jsoninto a single Node string viabytesToUtf8String + JSON.parsein two places, and both crash when the output is larger than V8'sString::kMaxLength(~512 MiB,0x1fffffe8). The whole test run aborts before a single test is started.The triggers are fast byte scans, so the work behind the gate is invisible to users:
solidity-test/inline-config/index.ts:152-158, incollectRawOverrides) — runs wheneverforge-config:orhardhat-config:bytes are present in the build info.solidity-test/eip712/index.ts:57-66, incollectEip712CanonicalTypes) — runs whenevertest.solidity.eip712Types.includeis set and the build info containsstruct(which is true for nearly every real Solidity project).Stack traces
Call site 1:
Call site 2 (after patching the first):
Minimal reproduction steps
Real project
Expected vs actual
npx hardhat test solidityon a project with a >512 MiB build-info outputERR_STRING_TOO_LONGthrown fromcollectRawOverridesorcollectEip712CanonicalTypes; whole run aborts before any test startsEnvironment
3.5.1and3.6.0(latest at the time of writing)@nomicfoundation/edr@0.12.0-next.33(unchanged across both Hardhat versions)v22.x731_669_005bytes (~698 MiB) for the default profileLayer
Pure Hardhat (test-runner plugin). Failure happens entirely inside the
solidity-testtask-action before EDR is invoked.Search terms
No response