question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

asm.js build of soljson 0.4.25 fails on node.js 14+

See original GitHub issue

It seems that legacy version 0.4.25 does not work for any contracts.

My code:

const path = require('path');
const fs = require('fs');
const solc = require('solc');
solc.loadRemoteVersion('v0.4.25+commit.59dbf8f1', function(err, solcSnapshot) {
    if (err) {
        console.error(err);
    } else {
        const input = {
            language: 'Solidity',
            sources: {
                'test.sol': {
                    content: fs.readFileSync(path.join(__dirname, 'testContract.sol'), {encoding: 'utf-8'}),
                }
            },
            settings: {
                outputSelection: {
                    '*': {
                        '*': ['*']
                    }
                }
            }
        };
        const output = JSON.parse(solcSnapshot.compile(JSON.stringify(input)));
        console.log(output);
    }
});

The contract is as simple as this:

pragma solidity ^0.4.25;

contract C{}

Output:

RangeError: Maximum call stack size exceeded
    at Object.$db [as dynCall_viiiiii] (soljson-v0.4.25+commit.59dbf8f1.js:12:120931)
    at invoke_viiiiii (soljson-v0.4.25+commit.59dbf8f1.js:1:1118207)
    at Array.pva (soljson-v0.4.25+commit.59dbf8f1.js:13:29030)
    at Object.M9a [as dynCall_vi] (soljson-v0.4.25+commit.59dbf8f1.js:12:99033)
    at invoke_vi (soljson-v0.4.25+commit.59dbf8f1.js:1:1115011)
    at Array.xta (soljson-v0.4.25+commit.59dbf8f1.js:10:704784)
    at Object.Dfb [as dynCall_iii] (soljson-v0.4.25+commit.59dbf8f1.js:12:130740)
    at invoke_iii (soljson-v0.4.25+commit.59dbf8f1.js:1:1119442)
    at Array.vta (soljson-v0.4.25+commit.59dbf8f1.js:10:703080)
    at Object.Yfb [as dynCall_iiiiii] (soljson-v0.4.25+commit.59dbf8f1.js:12:131900)

There is a similar issue #496. But the problem is not solved at all. That issue is closed only because the creator changed the compiler version. But this walkaround solution is not applicable to me. I am reproducing verified contracts on Etherscan and need to compile the contract using the exactly the same compiler version as required in the contract verification.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
cameelcommented, Jul 15, 2021

I can confirm the problem on 0.4.25, though I’m getting a different stack trace:

(node:366095) V8: soljson-v0.4.25+commit.59dbf8f1.js:3 Invalid asm.js: Invalid member of stdlib
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1025:15)
    at Module._compile (node:internal/modules/cjs/loader:1059:27)
    at requireFromString (/tmp/x/node_modules/require-from-string/index.js:28:4)
    at IncomingMessage.<anonymous> (/tmp/x/node_modules/solc/wrapper.js:338:35)
    at IncomingMessage.emit (node:events:406:35)
    at endReadableNT (node:internal/streams/readable:1329:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

Interestingly, it happens only on newer node.js versions (tried v16.4.2 and v14.16.0). No error on v12.22.0.

Also, the wasm 0.4.25 binary does not have this problem. I recommend using this binary over the asm.js one anyway.

Not sure if there’s anything we can do to fix this particular asm.js binary for newer node.js. At least we should update loadRemoteVersion() to download the wasm one when available.

0reactions
AndreMirascommented, Oct 26, 2022

I’m not too sure how to go about replacing the asm.js by the wasm one, but in my case increasing the stack-size got it to pass (for node 16).

node --stack-size=2000 index.js

Default size was 984 on my system:

node --v8-options | grep -B0 -A1 stack-size
  --stack-size (default size of stack region v8 is allowed to use (in kBytes))
        type: int  default: 984
Read more comments on GitHub >

github_iconTop Results From Across the Web

asm.js build of soljson 0.4.25 fails on node.js 14+ -
It seems that legacy version 0.4.25 does not work for any contracts. My code: const path = require('path'); const fs = require('fs'); ...
Read more >
Invalid member of stdlib) while trying to compile solidity 0.4.17 ...
25 binary: asm.js build of soljson 0.4.25 fails on node.js 14+ #537. Unfortunately I don't know what is the cause but if ...
Read more >
Events | Node.js v19.3.0 Documentation
When an error occurs within an EventEmitter instance, the typical action is for an 'error' event to be emitted. These are treated as...
Read more >
AWS Lambda function errors in Node.js
When your code raises an error, Lambda generates a JSON representation of the error. This error document appears in the invocation log and,...
Read more >
Npm install error(fails) - M220JS - MongoDB
Hi , I downloaded the mflix-js project and used npm install and it started to show ... installing npm i node-gyp , but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found