trufflesuite / ganache

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
2.62k stars 680 forks source link

Websocket server crashes on connection in Node Latest (v16) #941

Closed domohawk closed 3 years ago

domohawk commented 3 years ago

When using node latest (v16.6.2), ganache-cli crashes upon the connection attempt from the client. I've tested both rust-web3 and truffle web3js clients.

Stacktrace (ganache@canary):

RPC Listening on 127.0.0.1:8545
TypeError: r.unmask is not a function
    at unmask (/usr/lib/node_modules/ganache/dist/node/0.js:2:703750)
    at Receiver.getData (/usr/lib/node_modules/ganache/dist/node/0.js:2:2100034)
    at Receiver.startLoop (/usr/lib/node_modules/ganache/dist/node/0.js:2:2097050)
    at Receiver._write (/usr/lib/node_modules/ganache/dist/node/0.js:2:2096405)
    at writeOrBuffer (node:internal/streams/writable:389:12)
    at _write (node:internal/streams/writable:330:10)
    at Receiver.Writable.write (node:internal/streams/writable:334:10)
    at Socket.socketOnData (/usr/lib/node_modules/ganache/dist/node/0.js:2:2093912)
    at Socket.emit (node:events:394:28)
    at addChunk (node:internal/streams/readable:312:12)
davidmurdoch commented 3 years ago

We don't fully support Node 16 yet, but I just released a new @canary version that fixes some other issues that might fix this issue in Node 16 (it will use a JS based websocket library instead of native). Can you try it and let me know if the error is gone now?

domohawk commented 3 years ago

I updated but am still seeing the same stack trace (with different line numbers).

node v16.6.1
ganache v 7.0.0-canary.1338 (@ganache/cli: 0.1.1-canary.1336, @ganache/core: 0.1.1-canary.1336)
...
TypeError: r.unmask is not a function
    at unmask (/usr/lib/node_modules/ganache/dist/node/0.js:2:681419)
    at Receiver.getData (/usr/lib/node_modules/ganache/dist/node/0.js:2:2001080)
    at Receiver.startLoop (/usr/lib/node_modules/ganache/dist/node/0.js:2:1998461)
    at Receiver._write (/usr/lib/node_modules/ganache/dist/node/0.js:2:1997816)
    at writeOrBuffer (node:internal/streams/writable:389:12)
    at _write (node:internal/streams/writable:330:10)
    at Receiver.Writable.write (node:internal/streams/writable:334:10)
    at Socket.socketOnData (/usr/lib/node_modules/ganache/dist/node/0.js:2:1995903)
    at Socket.emit (node:events:394:28)
    at addChunk (node:internal/streams/readable:312:12)
davidmurdoch commented 3 years ago

I've got a fix for this specific issue as part of https://github.com/trufflesuite/ganache-core/pull/944, but noticed some other issues with the webpacked build when running in node 16, so it's not quite ready yet.

davidmurdoch commented 3 years ago

@domohawk do you mind testing the latest @canary release once again? npm install ganache@canary -g

domohawk commented 3 years ago

@davidmurdoch I'm no longer seeing the issue, but even more oddly after reinstalling ganache-cli (Ganache CLI v6.12.2 (ganache-core: 2.13.2)) it still works as well. Did you backport the fixes? I didn't even realize it was able to run a WS server since the pre-7 CLI doesn't have a --server.ws option. I just wanted to make sure I tested this properly.

davidmurdoch commented 3 years ago

No, we haven't back-ported any fixes; this bug must have been a regression in v7.

I'll close this issue since things seem to be resolved. Let me know if I've closed it prematurely! Thanks!