Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Metamask 4.12.0 crashes Ganache #186

Closed
sparrowDom opened this issue Oct 3, 2018 · 6 comments
Closed

Metamask 4.12.0 crashes Ganache #186

sparrowDom opened this issue Oct 3, 2018 · 6 comments

Comments

@sparrowDom
Copy link

sparrowDom commented Oct 3, 2018

After updating to Metamask 4.12.0 I have noticed that sometimes transactions crash local ganache process. Ganache is running on localhost's default port. Interestingly this never happens with Metamask 4.11.1.

This is the root cause of Ganache crash:

TypeError: Cannot read property 'connection' of undefined
    at ConnectionManager._updateSubscriptions (/app/ganache-core/lib/webSocketServer.js:135:70)
    at Provider.<anonymous> (/app/ganache-core/lib/webSocketServer.js:34:31)
    at Provider.emit (events.js:180:13)
    at Provider.emit (domain.js:422:20)
    at SubscriptionSubprovider.<anonymous> (/app/ganache-core/lib/provider.js:51:10)
    at SubscriptionSubprovider.emit (events.js:180:13)
    at SubscriptionSubprovider._notificationHandler (/app/ganache-core/node_modules/web3-provider-engine/subproviders/subscriptions.js:96:8)
    at Array.forEach (<anonymous>)
    at BlockFilter.<anonymous> (/app/ganache-core/node_modules/web3-provider-engine/subproviders/subscriptions.js:62:15)
    at BlockFilter.emit (events.js:180:13)
    at BlockFilter.emit (domain.js:422:20)
    at BlockFilter.update (/app/ganache-core/node_modules/web3-provider-engine/subproviders/filters.js:319:8)
    at Web3ProviderEngine.emit (events.js:185:15)
    at Web3ProviderEngine.emit (domain.js:422:20)
    at Web3ProviderEngine._setCurrentBlock (/app/ganache-core/node_modules/web3-provider-engine/index.js:165:8)
    at GanacheBlockTracker.Web3ProviderEngine.self._blockTracker.on (/app/ganache-core/node_modules/web3-provider-engine/index.js:35:10)
    at GanacheBlockTracker.emit (events.js:185:15)
    at GanacheBlockTracker.emit (domain.js:422:20)
    at GanacheBlockTracker._setCurrentBlock (/app/ganache-core/lib/block_tracker.js:63:8)
    at BlockchainDouble.emit (events.js:180:13)
    at BlockchainDouble.emit (domain.js:422:20)
    at async.parallel (/app/ganache-core/lib/blockchain_double.js:243:14)
    at /app/ganache-core/node_modules/async/dist/async.js:3888:9
    at /app/ganache-core/node_modules/async/dist/async.js:473:16
    at iteratorCallback (/app/ganache-core/node_modules/async/dist/async.js:1064:13)
    at /app/ganache-core/node_modules/async/dist/async.js:969:16
    at /app/ganache-core/node_modules/async/dist/async.js:3885:13
    at /app/ganache-core/node_modules/level-sublevel/shell.js:53:51

This is the transaction that causes Ganache to crash:

{ id: 7118224018323,
   jsonrpc: '2.0',
   params:
    [ '0xf8cb1884773594008301343b944c22b592b68fb46e579f146b9e2dea7ff5f9cab780b864ca27eb1c02c0239e6b1f00849910062e9a97d1687c86cdf92e13b2fbabe62cd86bba6e860000000000000000000000000000000000000000000000000000000000000000000000000000000000000000da8ecf9940f97a40bb83a31e22e8c0eb61a3ab4a8207f2a0345808461db12fe12842dc1dd171e1cb17ab6dddbefacb15227c998cd3c546eba032fe7f49515f0b78d213e323e4a180519d9915488e1af8de398801f7f88a8801' ],
   method: 'eth_sendRawTransaction' 
}

and immediately after that transaction is received this function is called in Ganache: https://github.com/trufflesuite/ganache-core/blob/v2.2.1/lib/webSocketServer.js#L32 and this is the nofitication parameter passed to the function

{ jsonrpc: '2.0',
   method: 'eth_subscription',
   params:
    { subscription: '0x8',
      result:
       { hash: '0xffdc452286493f2c9ab10ccb6474911698e91052d4b6786d19c78037d6936b24',
         parentHash: '0xf672de0d7c4857ab042a7dcfb469e148feacb97e0f035781ab6a29b8277c4f9e',
         sha3Uncles: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347',
         miner: '0x0000000000000000000000000000000000000000',
         stateRoot: '0xd221b78d56a0132ab9097c3865fe0a3b19ee9c8372c29b7372dcd6992e6517ca',
         transactionsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
         receiptsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
         logsBloom: '0x00000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000008000000000000000000000000000000000000000000000000000001000800000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000100000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000040080000000000010000000000000000000000000000000000000000000000000000000000000',
         difficulty: '0x0',
         number: '0x27',
         gasLimit: '0x6691b7',
         gasUsed: '0x1343b',
         nonce: '0x0000000000000000',
         timestamp: '0x5bb4d49c',
         extraData: '0x' 
        }
    }
}

and provider that triggers the data event:

Provider {
   _events: { data: [Function] },
   _eventsCount: 1,
   _maxListeners: undefined,
   options:
    { vmErrorsOnRPCResponse: true,
      verbose: false,
      asyncRequestProcessing: false,
      logger:
       Console {
         log: [Function: bound consoleCall],
         debug: [Function: bound consoleCall],
         info: [Function: bound consoleCall],
         dirxml: [Function: bound consoleCall],
         warn: [Function: bound consoleCall],
         error: [Function: bound consoleCall],
         dir: [Function: bound consoleCall],
         time: [Function: bound consoleCall],
         timeEnd: [Function: bound consoleCall],
         trace: [Function: bound consoleCall],
         assert: [Function: bound consoleCall],
         clear: [Function: bound consoleCall],
         count: [Function: bound consoleCall],
         countReset: [Function: bound countReset],
         group: [Function: bound consoleCall],
         groupCollapsed: [Function: bound consoleCall],
         groupEnd: [Function: bound consoleCall],
         Console: [Function: Console],
         table: [Function: table],
         markTimeline: [Function: markTimeline],
         profile: [Function: profile],
         profileEnd: [Function: profileEnd],
         timeline: [Function: timeline],
         timelineEnd: [Function: timelineEnd],
         timeStamp: [Function: timeStamp],
         context: [Function: context],
         [Symbol(counts)]: Map {} },
      ws: true,
      total_accounts: 10,
      default_balance_ether: 100,
      network_id: 999,
      seed: 123,
      blocktime: 0,
      mnemonic: 'bring drip better sample dirt plug bargain company hazard faint muffin produce',
      gasPrice: '0x77359400',
      unlocked_accounts: [],
      hdPath: 'm/44\'/60\'/0\'/0/',
      gasLimit: '0x6691b7',
      defaultTransactionGasLimit: '0x15f90',
      time: null,
      debug: false,
      allowUnlimitedContractSize: false },
   engine:
    Web3ProviderEngine {
      _events: { block: [Array] },
      _eventsCount: 1,
      _maxListeners: 100,
      _blockTracker:
       GanacheBlockTracker {
         _events: [Object],
         _eventsCount: 3,
         _maxListeners: undefined,
         _blockchain: [BlockchainDouble],
         start: [Function: bound ],
         stop: [Function: bound ],
         getTrackingBlock: [Function: bound ],
         awaitCurrentBlock: [Function: bound ],
         _setCurrentBlock: [Function: bound ],
         _currentBlock: [Object] },
      _ready:
       Stoplight {
         _events: {},
         _eventsCount: 0,
         _maxListeners: undefined,
         isLocked: false },
      currentBlock:
       { number: <Buffer 27>,
         hash: <Buffer ff dc 45 22 86 49 3f 2c 9a b1 0c cb 64 74 91 16 98 e9 10 52 d4 b6 78 6d 19 c7 80 37 d6 93 6b 24>,
         parentHash: <Buffer f6 72 de 0d 7c 48 57 ab 04 2a 7d cf b4 69 e1 48 fe ac b9 7e 0f 03 57 81 ab 6a 29 b8 27 7c 4f 9e>,
         nonce: <Buffer 00 00 00 00 00 00 00 00>,
         sha3Uncles: <Buffer 1d cc 4d e8 de c7 5d 7a ab 85 b5 67 b6 cc d4 1a d3 12 45 1b 94 8a 74 13 f0 a1 42 fd 40 d4 93 47>,
         logsBloom: <Buffer 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... >,
         transactionsRoot: <Buffer 56 e8 1f 17 1b cc 55 a6 ff 83 45 e6 92 c0 f8 6e 5b 48 e0 1b 99 6c ad c0 01 62 2f b5 e3 63 b4 21>,
         stateRoot: <Buffer d2 21 b7 8d 56 a0 13 2a b9 09 7c 38 65 fe 0a 3b 19 ee 9c 83 72 c2 9b 73 72 dc d6 99 2e 65 17 ca>,
         receiptsRoot: <Buffer 56 e8 1f 17 1b cc 55 a6 ff 83 45 e6 92 c0 f8 6e 5b 48 e0 1b 99 6c ad c0 01 62 2f b5 e3 63 b4 21>,
         miner: <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00>,
         difficulty: <Buffer 00>,
         totalDifficulty: <Buffer 00>,
         size: <Buffer 03 e8>,
         extraData: <Buffer >,
         gasLimit: <Buffer 66 91 b7>,
         gasUsed: <Buffer 01 34 3b>,
         timestamp: <Buffer 5b b4 d4 9c>,
         transactions: [Array] },
      _providers:
       [ [RequestFunnel],
         [DelayedBlockFilter],
         [SubscriptionSubprovider],
         [GethDefaults],
         [GethApiDouble] ],
      manager:
       GethApiDouble {
         state: [StateManager],
         options: [Object],
         initialized: true,
         initialization_error: null,
         post_initialization_callbacks: [],
         engine: [Circular],
         currentBlock: [Object] } },
   manager:
    GethApiDouble {
      state:
       StateManager {
         options: [Object],
         blockchain: [BlockchainDouble],
         vm: undefined,
         stateTrie: undefined,
         accounts: [Object],
         secure: false,
         account_passwords: {},
         personal_accounts: [Object],
         total_accounts: 10,
         coinbase: '0xda8ecf9940f97a40bb83a31e22e8c0eb61a3ab4a',
         latest_filter_id: 1,
         action_queue: [],
         snapshots: [],
         logger: [Console],
         net_version: 999,
         mnemonic: 'bring drip better sample dirt plug bargain company hazard faint muffin produce',
         wallet: [EthereumHDKey],
         wallet_hdpath: 'm/44\'/60\'/0\'/0/',
         gasPriceVal: '0x77359400',
         is_mining: true,
         blockTime: undefined,
         is_mining_on_interval: false,
         mining_interval_timeout: null,
         _provider: [Circular],
         unlocked_accounts: [Object],
         action_processing: true },
      options:
       { vmErrorsOnRPCResponse: true,
         verbose: false,
         asyncRequestProcessing: false,
         logger: [Console],
         ws: true,
         total_accounts: 10,
         default_balance_ether: 100,
         network_id: 999,
         seed: 123,
         blocktime: 0,
         mnemonic: 'bring drip better sample dirt plug bargain company hazard faint muffin produce',
         gasPrice: '0x77359400',
         unlocked_accounts: [],
         hdPath: 'm/44\'/60\'/0\'/0/',
         gasLimit: '0x6691b7',
         defaultTransactionGasLimit: '0x15f90',
         time: null,
         debug: false,
         allowUnlimitedContractSize: false },
      initialized: true,
      initialization_error: null,
      post_initialization_callbacks: [],
      engine:
       Web3ProviderEngine {
         _events: [Object],
         _eventsCount: 1,
         _maxListeners: 100,
         _blockTracker: [GanacheBlockTracker],
         _ready: [Stoplight],
         currentBlock: [Object],
         _providers: [Array],
         manager: [Circular] },
      currentBlock:
       { number: <Buffer 27>,
         hash: <Buffer ff dc 45 22 86 49 3f 2c 9a b1 0c cb 64 74 91 16 98 e9 10 52 d4 b6 78 6d 19 c7 80 37 d6 93 6b 24>,
         parentHash: <Buffer f6 72 de 0d 7c 48 57 ab 04 2a 7d cf b4 69 e1 48 fe ac b9 7e 0f 03 57 81 ab 6a 29 b8 27 7c 4f 9e>,
         nonce: <Buffer 00 00 00 00 00 00 00 00>,
         sha3Uncles: <Buffer 1d cc 4d e8 de c7 5d 7a ab 85 b5 67 b6 cc d4 1a d3 12 45 1b 94 8a 74 13 f0 a1 42 fd 40 d4 93 47>,
         logsBloom: <Buffer 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... >,
         transactionsRoot: <Buffer 56 e8 1f 17 1b cc 55 a6 ff 83 45 e6 92 c0 f8 6e 5b 48 e0 1b 99 6c ad c0 01 62 2f b5 e3 63 b4 21>,
         stateRoot: <Buffer d2 21 b7 8d 56 a0 13 2a b9 09 7c 38 65 fe 0a 3b 19 ee 9c 83 72 c2 9b 73 72 dc d6 99 2e 65 17 ca>,
         receiptsRoot: <Buffer 56 e8 1f 17 1b cc 55 a6 ff 83 45 e6 92 c0 f8 6e 5b 48 e0 1b 99 6c ad c0 01 62 2f b5 e3 63 b4 21>,
         miner: <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00>,
         difficulty: <Buffer 00>,
         totalDifficulty: <Buffer 00>,
         size: <Buffer 03 e8>,
         extraData: <Buffer >,
         gasLimit: <Buffer 66 91 b7>,
         gasUsed: <Buffer 01 34 3b>,
         timestamp: <Buffer 5b b4 d4 9c>,
         transactions: [Array] } },
   sendAsync: [Function: bound ],
   send: [Function: bound ],
   close: [Function: bound ],
   _queueRequest: [Function: bound ],
   _processRequestQueue: [Function: bound ],
   _requestQueue: [],
   _requestInProgress: true 
}

The process exits because no web socket connections have been made (I had logs setup in various places in webSocketServer.js and this.connectionsBySubscriptionId class variable is just an empty object. (hence the Cannot read property 'connection' of undefined error)

I realise this could most possibly be a Metamask problem, but the crash happens in Ganache. I was hoping someone can shed some light on what is going on.

Context

This prevents local development of the DApp I am working on.

Your Environment

  • Version used: v2.1.0 -> but have also tested on 2.2.1 and it crashes with the same error
  • Environment name and version: node v9.11.2
  • Operating System and version: Debian GNU/Linux 8 (jessie)
  • Link to your project: https://demo.staging.originprotocol.com/#/
@benjamincburns
Copy link
Contributor

It sounds like our error handling & messages aren't up to snuff here. From #930 (a duplicate of this issue) it sounds like reverting to a prior version of MetaMask works around this issue in the interim.

@sparrowDom
Copy link
Author

@benjamincburns Metamask acknowledged a 4.12.0 as a broken build and reverted some changes in 4.13.0. That version does not break Ganache anymore.

@sreepriyasreekumar
Copy link

I am facing the same issue while using trufflesuite/ganache-cli:v6.1.8 and web3: 1.0.0-beta.33

TypeError: Cannot read property 'connection' of undefined
at n._updateSubscriptions (/src/build/cli.node.js:65:5443)
at l. (/src/build/cli.node.js:65:3860)
at emitTwo (events.js:126:13)
at l.emit (events.js:214:7)
at o. (/src/build/cli.node.js:37:29806)
at emitTwo (events.js:126:13)
at o.emit (events.js:214:7)
at o._notificationHandler (/src/build/cli.node.js:149:95910)
at Array.forEach ()
at b. (/src/build/cli.node.js:149:95414)
at emitOne (events.js:116:13)
at b.emit (events.js:211:7)
at b.update (/src/build/cli.node.js:149:93983)
at /src/build/cli.node.js:149:90733
at /src/build/cli.node.js:149:92968
at /src/build/cli.node.js:149:224894
at /src/build/cli.node.js:37:15061
at h (/src/build/cli.node.js:37:15496)
at /src/build/cli.node.js:37:15549
at a.default (/src/build/cli.node.js:149:104428)
at /src/build/cli.node.js:37:14433
at i (/src/build/cli.node.js:149:224738)

@nicholasjpaterno
Copy link
Contributor

@sreepriyasreekumar Thanks for reporting! We've identified the root cause and believe we have a fix which you can checkout here - if you have a chance to check this out, please report back here or open a new issue if you still experience this bug. My goal is to have this fix included in our next incremental release. Thanks again for taking the time to report this!

@nicholasjpaterno
Copy link
Contributor

#252 Fixed in develop.

@imthatcarlos
Copy link

imthatcarlos commented Jan 20, 2019

@nicholasjpaterno not so sure develop is stable. I had a similar issue with subscriptions and decided to build ganache-cli locally to use the develop branch, run on docker, and now the migrations are still good, but it hangs on the first test I run.

Ganache CLI v6.2.5 (ganache-core: 2.4.0-beta.0)
migrations...
eth_subscribe
eth_getCode
eth_getBlockByNumber
eth_getBlockByNumber
indefinitely...

EDIT: Nevermind, I'm an idiot 0xProject/0x-monorepo#1520

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants