Truffle: "callback already called" error

Created on 26 Apr 2020  ·  24Comments  ·  Source: trufflesuite/truffle

  • [x] I've asked for help in the Truffle Gitter before filing this issue.

Issue

Deploying on testnet fails with Error: callback already called (but deployment on Ganache succeeds).
The mentioned callback is at /node_modules/truffle/build/webpack:/~/ganache-core/~/merkle-patricia-tree/~/async/lib/async.js:358.

Steps to Reproduce

npx truffle unbox okwme/truffle-shavings

Create the .env as required here https://github.com/okwme/truffle-shavings
Delete truffle-config,js

yarn migrate --network rinkeby

You should get the error

Expected Behavior

Contract should be deployed on Rinkby or any other testnet

Actual Results

$yarn migrate --network rinkeby
yarn run v1.22.4
$ npx truffle migrate --network rinkeby

Compiling your contracts...
===========================
> Compiling ./contracts/Migrations.sol
> Compiling ./contracts/Sample.sol
> Artifacts written to /Users/Pm/Documents/Ethereum/test2/build/contracts
> Compiled successfully using:
   - solc: 0.5.0+commit.1d4f565a.Emscripten.clang


/Users/Pm/Documents/Ethereum/test2/node_modules/truffle/build/webpack:/~/ganache-core/~/merkle-patricia-tree/~/async/lib/async.js:358
                callback(err);
^
Error: Callback was already called.
    at /Users/Pm/Documents/Ethereum/test2/node_modules/truffle/build/webpack:/~/ganache-core/~/merkle-patricia-tree/~/async/lib/async.js:43:1
    at WriteStream.<anonymous> (/Users/Pm/Documents/Ethereum/test2/node_modules/truffle/build/webpack:/~/ganache-core/~/merkle-patricia-tree/~/async/lib/async.js:358:1)
    at WriteStream.emit (events.js:315:20)
    at WriteStream.destroy (/Users/Pm/Documents/Ethereum/test2/node_modules/truffle/build/webpack:/~/level-ws/level-ws.js:140:1)
    at finish (_stream_writable.js:681:14)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Environment

  • OSX 10.15.3 (Catalina)
  • Web3.js v1.2.1
  • Truffle v5.1.23 (core: 5.1.23)
    • Solidity v0.5.16 (solc-js)
  • Node v14.0.0
  • npm 6.14.4
    • yarn 1.22.4
priority2 ⚠️

Most helpful comment

@PierreMarieRiviere This is an issue related to ganache-core's internals not yet being Node 14 compatible (https://github.com/trufflesuite/ganache-cli/issues/732).

You _should_ be able to to deploy to any of the production networks (including testnets) with truffle on Node 14, by skipping the dry run (truffle migrate --network rinkeby --skipDryRun). The dry run uses ganache's forking feature to simulate the deployment for production networks.

All 24 comments

To anyone meeting this problem it could be due to
(1) Node 14. Revert to LTS (12.16.2 at time of writing)
(2) Anything else. Sorry. I formatted my computer in the meantime. Maybe some elder sudo messing up with my config.

@TheDApact thanks for reporting this and for the repro steps! I'll take a look into why this is happening.

I was unable to duplicate your error. I tried with both Node 10 and 12. I could successfully migrate to ropsten like you instructed. I wonder what could be going on here.

I was on Node 14.0 best bet it's from Node.

Node 12.0 does it!

I was able to on Node 14 too. Try upgrading your version of Truffle in the package.json. Currently it is set at ^5.0.2. Set it to at least ^5.1.0. My guess is that you are experiencing a bug we have already fixed. I was using the latest version of Truffle installed globally on my machine. Let me know what happens.

Still getting the same error with node 14.0 after upgrading truffle to ^5.1.0 in package.json.

At least we confirmed it stems from node 14.0

edit: same with 5.1.23

No I meant to say that I was able to successfully migrate to ropsten using Node 14. I'm not sure what's up with this. Are you using a globally installed version of Truffle? If so, can you do a truffle version just to ensure you are using the most recent version? I know we had some bug a while back that gave the error message that you reported...

Here is my environment

Truffle v5.1.23 (core: 5.1.23)
Solidity v0.5.16 (solc-js)
Node v14.0.0
Web3.js v1.2.1

npx truffle migrate will work if I downgrade Node to 12.16.2

Here are the packages installed globally on my (just formatted) OSX Catalina

├── [email protected]
├── [email protected]
└── [email protected]

Worse mentioning that I added the snippet below to package.json found in the box, to fix an error with fsevent (see https://github.com/nodejs/node/issues/27389)

"resolutions": {
    "**/**/fsevents": "^1.2.9"
 },

Hmm weird, it looks like I can duplicate your error with Node 14 today. I think it is unrelated to the resolutions property you mentioned above as I could duplicate it without it. We'll have to look into this later, thanks for the report! I really would like to get rid of the async library from the Truffle codebase :)

I really would like to get rid of the async library from the Truffle codebase :)

Your wish is my command :genie:

So the async library was removed from the latest version of Truffle (5.1.25) and re-attempting this migration I get the same error. So it looks like this error does not come from Truffle's direct usage of the library but is rather something else. More investigation will be necessary.

Same error with this:

Truffle v5.1.25 (core: 5.1.25)
Solidity - 0.6.6 (solc-js)
Node v14.2.0
Web3.js v1.2.1

But everything is just fine with this:

Truffle v5.1.8 (core: 5.1.8)
Solidity - 0.6.6 (solc-js)
Node v12.14.1
Web3.js v1.2.1

Hello

I am having the same error. Is this a bug?

/versions/node/v14.3.0/lib/node_modules/truffle/build/webpack:/node_modules/merkle-patricia-tree/node_modules/async/lib/async.js:358
callback(err);
^
Error: Callback was already called.

Truffle v5.1.28 (core: 5.1.28)
Solidity - 0.6.8 (solc-js)
Node v14.3.0
Web3.js v1.2.1

Thank you

Will

I was experiencing the same problem with Node v14.4.0
After switching to Node v12.0.0 with nvm it worked like a charm.

@PierreMarieRiviere This is an issue related to ganache-core's internals not yet being Node 14 compatible (https://github.com/trufflesuite/ganache-cli/issues/732).

You _should_ be able to to deploy to any of the production networks (including testnets) with truffle on Node 14, by skipping the dry run (truffle migrate --network rinkeby --skipDryRun). The dry run uses ganache's forking feature to simulate the deployment for production networks.

I was experiencing the same problem with the following setting:
Truffle v5.1.31
node v14.4.0
Solidity v0.5.0

It works for me after I tried 'truffle migrate --network rinkeby --skipDryRun'

@PierreMarieRiviere This is an issue related to ganache-core's internals not yet being Node 14 compatible (trufflesuite/ganache-cli#732).

You _should_ be able to to deploy to any of the production networks (including testnets) with truffle on Node 14, by skipping the dry run (truffle migrate --network rinkeby --skipDryRun). The dry run uses ganache's forking feature to simulate the deployment for production networks.

Thank you !

same issue.
Truffle v5.1.41 (core: 5.1.41)
Solidity v0.5.16 (solc-js)
Node v14.5.0
Web3.js v1.2.1

My experience is that it is broken with N0de v14 - revert to v12.

On Wed, 26 Aug 2020 at 10:09, Tanja Nyberg notifications@github.com wrote:

same issue.
Truffle v5.1.41 (core: 5.1.41)
Solidity v0.5.16 (solc-js)
Node v14.5.0
Web3.js v1.2.1


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/trufflesuite/truffle/issues/3008#issuecomment-680758669,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ACGV6IL5FLRK2FDFW6ZLZTDSCTGOBANCNFSM4MRDSLHQ
.

'truffle migrate --network ropsten --skipDryRun' worked for me though.

--skipDryRun

Nice!

On Wed, 26 Aug 2020 at 11:36, Tanja Nyberg notifications@github.com wrote:

'truffle migrate --network ropsten --skipDryRun' worked for me though.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/trufflesuite/truffle/issues/3008#issuecomment-680800053,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ACGV6II6XGCQW7KWGSZU2ZTSCTQSHANCNFSM4MRDSLHQ
.

Skipping Dry Run also worked for me.

Note: it can be added in the networks configs in truffle-config.js as skipDryRun: true as well!

Why isn't this issue closed already? Or are there implications on skipping the dry run, so waiting for a "permanent" fix?

Is there anything else actionable here on this issue (other than supporting Node 14)? Just to reiterate, Truffle is not currently compatible with Node 14. Part of the problem is that Ganache is not yet compatible with Node 14 and Truffle uses that "under the hood".

had same issue with migrate to any live network:
Environment:
Truffle v5.1.46 (core: 5.1.46)
Solidity v0.5.16 (solc-js)
Node v14.13.0
Web3.js v1.2.1

skipDryRun worked for me too....
@CruzMolina Thanks...

@ashu12318 Try upgrading to the latest Truffle. It is only as of Truffle version 5.1.49 that Truffle has been compatible with Node 14.

Was this page helpful?
0 / 5 - 0 ratings