Testing with Node 14 ganache-core errors with Callback was already called

test run failed after update node version from 12 to 14.

:computer: Environment
Version: v14.4.0

  "@openzeppelin/test-environment": "^0.1.4",
  "@openzeppelin/test-helpers": "^0.5.6"

:memo:Details
I got the same error use clear code way after test run failed。

:1234: Code to reproduce

// JS: main.js
function square(x) {
    return new Promise(resolve => {
        setTimeout(() => {
            resolve(Math.pow(x, 2));
        }, 1000);
    });
}

const { accounts } = require('@openzeppelin/test-environment');
const { balance } = require('@openzeppelin/test-helpers');


console.log("Version:", process.version)


square(222).then(data => {
    console.log("Good Call:", data);
}).then(() => {
    balance.current(accounts[0]).then(v => {
        console.log("balance:", v)
    })
});

// File: package.json
{
  "name": "asynctest",
  "version": "1.0.0",
  "description": "",
  "main": "main.js",
  "dependencies": {},
  "devDependencies": {
    "@openzeppelin/test-environment": "^0.1.4",
    "@openzeppelin/test-helpers": "^0.5.6"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

error info

asynctest node main.js
Version: v14.4.0
Good Call: 49284

/Users/ysqi/Downloads/asynctest/node_modules/ganache-core/node_modules/merkle-patricia-tree/node_modules/async/lib/async.js:358
                callback(err);
                ^
Error: Callback was already called.
    at /Users/ysqi/Downloads/asynctest/node_modules/ganache-core/node_modules/merkle-patricia-tree/node_modules/async/lib/async.js:43:36
    at WriteStream.<anonymous> (/Users/ysqi/Downloads/asynctest/node_modules/ganache-core/node_modules/merkle-patricia-tree/node_modules/async/lib/async.js:358:17)
    at WriteStream.emit (events.js:315:20)
    at WriteStream.destroy (/Users/ysqi/Downloads/asynctest/node_modules/ganache-core/node_modules/level-ws/level-ws.js:140:8)
    at finish (_stream_writable.js:658:14)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
2 Likes

Hi @ysqi,

Unfortunately there is an issue with ganache-core and node 14:

Until this is resolved, I suggest using node 12 or earlier. I use node 10.

I have created an issue to track: https://github.com/OpenZeppelin/openzeppelin-test-environment/issues/123

Hi @ysqi,

I wanted to check if you were able to test using an earlier version of node?

After switching back to node v12.18.0, it works!

2 Likes

Hi @ysqi,

Glad to hear that you are up and running.

tks, Chinese developers need OZ, or at least I need OZ!

1 Like