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 676 forks source link

Forking an invalid url @ a block number in published builds infinite loops on close. #4138

Open tenthirtyone opened 1 year ago

tenthirtyone commented 1 year ago

Note: This exists in production ganache. I have not been able to get it to reproduce in development.

Description

Running ganache and forking @ a block number causes this issue when no server is running at the url/port.

Reproduce

  1. Start a build ganache and fork from any url at a block number.
  2. Ctrl+c to stop ganache

Expected: Ganache is killed Actual:

ganache --fork.url http://127.0.0.1:8545@1 

ganache v7.7.2 (@ganache/cli: 0.8.1, @ganache/core: 0.8.1)
Starting RPC server
^C
Received shutdown signal: SIGINT
Shutting down…
^C
Received shutdown signal: SIGINT
^C
Received shutdown signal: SIGINT
^C
Received shutdown signal: SIGINT
^C
Received shutdown signal: SIGINT

The process never terminates. Users will be required to ps -ef | grep ganache and run kill. I do not know of the Windows behavior, I have not set Virtual Box up since my yearly rebuild over holiday.

Running without the block number will eventually result in a socket hangup, however the user can still spam Ctrl+c in that period and achieve the same result:

ganache --fork.url http://127.0.0.1:8545                                                                                                                                                                                                     hayek@rothbard
ganache v7.7.2 (@ganache/cli: 0.8.1, @ganache/core: 0.8.1)
Starting RPC server
eth_chainId
^C
Received shutdown signal: SIGINT
Shutting down…
^C
Received shutdown signal: SIGINT
^C
Received shutdown signal: SIGINT
^C
Received shutdown signal: SIGINT
^C
Received shutdown signal: SIGINT
Error: socket hang up
    at connResetException (internal/errors.js:639:14)
    at Socket.socketCloseListener (_http_client.js:449:25)
    at Socket.emit (events.js:412:35)
    at TCP.<anonymous> (net.js:686:12) {
  code: 'ECONNRESET'
}

Running the same commands in a dev env:

ganache vDEV (@ganache/cli: DEV, @ganache/core: DEV)
Starting RPC server
^C
Received shutdown signal: SIGINT
Shutting down…
Waiting for the debugger to disconnect...

Received shutdown signal: SIGINT
Waiting for the debugger to disconnect...

Then... wait for it like 10 seconds....

 Error: connect ETIMEDOUT 0.0.0.1:80                                                                                                                 
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16)
    at TCPConnectWrap.callbackTrampoline (internal/async_hooks.js:130:17) {
  errno: -110,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '0.0.0.1',
  port: 80
}
Error: connect ETIMEDOUT 0.0.0.1:80
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16)
    at TCPConnectWrap.callbackTrampoline (internal/async_hooks.js:130:17) {
  errno: -110,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '0.0.0.1',
  port: 80
}