MetaMask / web3-provider-engine

A JavaScript library for composing Ethereum provider objects using middleware modules
MIT License
597 stars 328 forks source link

connection event listener registration error #322

Closed emarteca closed 1 year ago

emarteca commented 4 years ago

Hi all, I've been working on a tool to identify instances of events registered to the wrong object in uses of some JavaScript event-driven APIs, as part of a research project. The tool flagged line 39 in subproviders/ipc.js, on the registration of the listener for "connection": https://github.com/MetaMask/web3-provider-engine/blob/master/subproviders/ipc.js#L39

The reason I believe this is an error is as follows (from looking at the nodejs net API documentation, particularly https://nodejs.org/api/net.html#net_net_createconnection): client is a net.Socket, as the return of net.connect(...) (which is an alias for net.createConnection( ... )). "connection" is an event on net.Server, and not on net.Socket (which has event "connect" instead). So, my guess is that the code here should instead be "client.on('connect', ....)"

Thanks!

mcmire commented 1 year ago

Sorry that you ran into this bug. We are actively phasing out this package in favor of json-rpc-engine and its related packages and are no longer accepting fixes, however, so I'm going to close this.