Truffle console fails to connect to testnets if there's a compiled contract/library called Buffer

:computer: Environment
Windows 10 (also tested on Ubuntu 18.04)
Node.js 13.11.0
Truffle 5.1.18
@truffle/hdwallet-provider 1.0.33
solc 0.6.4

Experiencing a weird issue in truffle… Where if you have a compiled contract or library named exactly Buffer, then truffle console fails to connect to a testnet (at least through an infura node). If someone would like to try to reproduce this, I’ve created a small repo that will test it. It appears to happen with any Node version 12.0.0 and higher. Lower versions work OK.

:1234: Code to reproduce

1 Like

I made it in Node 12.13.1 and Rinkeby.

:computer: Environment
Windows 10
Truffle v5.1.11 (core: 5.1.11)
Solidity - 0.6.4 (solc-js)
Node v12.13.1
Web3.js v1.2.1

You can find the contract Etherscan:
Deployed contract on Rinkeby

1 Like

Deploying wasn’t the issue… Just opening truffle console. Were you able to do that? Perhaps you’ve got a different setup somehow…

1 Like

It works.
truffle(rinkeby)> myContract = new web3.eth.Contract([], '0x3612A5A494155455433AB16a82964753EcdA5F32');

Maybe different setup…or Buffer is same as Buffer in Node.js?

1 Like

Hi @coffee-converter,

It worked on node 10, I had installation issues running on node 12 and node 13.
This was on WSL (1).

Yeah, the bug seems to only happen in Node 12+. Truffle devs have reproduced it. Looks to be a collision between some versions of web3 and Node.

1 Like

FYI here’s the open issue on truffle’s github, in case any one else wants to monitor this:

1 Like