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.

Ganache crashes when running truffle debug

See original GitHub issue

I am running ganache 1.3

My test code appears to run successfully, and I am able to see the transaction appear in ganache. However, when I run truffle debug txId I get the following error:

RangeError: Invalid string length
    at JSON.stringify (<anonymous>)
    at /node_modules/ganache-core/lib/httpServer.js:103:57
    at Object.intermediary [as callback] (/node_modules/ganache-core/lib/provider.js:114:5)
    at self.engine.sendAsync (/node_modules/ganache-core/lib/provider.js:169:12)
    at /node_modules/ganache-core/node_modules/web3-provider-engine/index.js:152:9
    at /node_modules/ganache-core/node_modules/async/internal/once.js:12:16
    at replenish (/node_modules/ganache-core/node_modules/async/internal/eachOfLimit.js:61:25)
    at /node_modules/ganache-core/node_modules/async/internal/eachOfLimit.js:71:9
    at eachLimit (/node_modules/ganache-core/node_modules/async/eachLimit.js:43:36)
    at /node_modules/ganache-core/node_modules/async/internal/doLimit.js:9:16
    at Object.end [as callback] (/node_modules/ganache-core/node_modules/web3-provider-engine/index.js:127:5)
    at intermediary (/node_modules/ganache-core/lib/statemanager.js:401:12)
    at /node_modules/ganache-core/lib/blockchain_double.js:900:11
    at /node_modules/ganache-core/lib/blockchain_double.js:649:9
    at commmitIfNeeded (/node_modules/ganache-core/lib/blockchain_double.js:640:11)
    at /node_modules/ganache-core/lib/blockchain_double.js:644:7
    at /node_modules/ganache-core/node_modules/async/internal/once.js:12:16
    at replenish (/node_modules/ganache-core/node_modules/async/internal/eachOfLimit.js:61:25)
    at /node_modules/ganache-core/node_modules/async/internal/eachOfLimit.js:71:9
    at eachLimit (/node_modules/ganache-core/node_modules/async/eachLimit.js:43:36)
    at /node_modules/ganache-core/node_modules/async/internal/doLimit.js:9:16
    at VM.AsyncEventEmitter.emit (/node_modules/ganache-core/node_modules/async-eventemitter/lib/AsyncEventEmitter.js:42:3)

This error occurs when debugging any transaction and causes ganache to crash.

Currently running macOS Mojave 10.14

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Gdocalcommented, Mar 10, 2021

I get this issue often. I use brownie + ganache-cli, when tx reverts (gas usage: 2m) brwonie sends debug_traceTransaction, and ganache crashes after this

file ganache-core.node.cli.js switch (o) { case "POST": var d; try { d = JSON.parse(f); } catch (e) { return (s["Content-Type"] = "text/plain"), void c(n, 400, s, "400 Bad Request"); } if (d instanceof Array) for (var u = 0; u < d.length; u++) { var b = d[u]; t.log(b.method); } else t.log(d.method); if ("eth_subscribe" === d.method || "eth_unsubscribe" === d.method) { (s["Content-Type"] = "application/json"), c(n, 400, s, a(d.id, -32e3, "notifications not supported")); break; } e.send(d, function (e, t) { (s["Content-Type"] = "application/json"), c(n, 200, s, JSON.stringify(t)); //<---------------- CRASHED HERE }); break; case "OPTIONS": c(n, 204, s); break; default: (s["Content-Type"] = "text/plain"), c(n, 400, s, "400 Bad Request"); } });

1reaction
davidmurdochcommented, Jul 12, 2019

I believe this happens when the data ganache attempts to send back to the client is too large for the current node process to JSON.stringify; it just runs out of available memory. One way to solve this is to start the ganache server process with more memory (--max-old-space-size=8192), another is for ganache to implement https://github.com/trufflesuite/ganache-core/issues/381 and from truffle debug to use it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to debug transaction from truffle test on development ...
Ganache is still crashing though when I run truffle debug, I added the stack trace to my original post. – Zargoon. Feb 25,...
Read more >
Use Truffle Develop and the Console
This tells you you're running within a Truffle console using the development network. Truffle Develop¶. To launch Truffle Develop: truffle develop. This will ......
Read more >
Debugging a smart contract - Truffle Suite
Open a second terminal and run truffle develop to start a development ... This will allow us to, for example, see transaction IDs...
Read more >
Debug Smart Contracts with Truffle and Ganache (in 2022)
In this Video you are going to learn how to use the Truffle Debugger. Used correctly, it can be a game-changer in your...
Read more >
Ethereum DApp with EVM, Remix, GoLang, Truffle, Drizzle ...
To try the debugging features, let's intentionally introduce a bug into the Ctontine contract and redeploy it into Ganache. Afterward, we will run...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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