Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removeAllListeners throws error #1458

Closed
nionis opened this issue Apr 12, 2021 · 3 comments
Closed

removeAllListeners throws error #1458

nionis opened this issue Apr 12, 2021 · 3 comments
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published.

Comments

@nionis
Copy link

nionis commented Apr 12, 2021

Hello everybody!

I have encountered this issue when running:

provider.removeAllListeners()
myContract.removeAllListeners()
Error: invalid event - null
    at getEventTag (/somepath/node_modules/@ethersproject/providers/src.ts/base-provider.ts:102:11)
    at WebSocketProvider.BaseProvider.off (/somepath/node_modules/@ethersproject/providers/src.ts/base-provider.ts:1569:24)
    at Contract.BaseContract._checkRunningEvents (/somepath/node_modules/@ethersproject/contracts/src.ts/index.ts:921:31)
    at Contract.BaseContract.removeAllListeners (/somepath/node_modules/@ethersproject/contracts/src.ts/index.ts:1066:22)
    at Indexer.stop (/somepath/packages/core-ethereum/src/indexer/index.ts:118:41)
    at /somepath/packages/core-ethereum/src/index.ts:106:32

the relevant code looks like this:

    // subscribe to new blocks
    provider
      .on('block', (blockNumber: number) => {
        this.onNewBlock({ number: blockNumber })
      })
      .on('error', (error: any) => {
        log(chalk.red(`etherjs error: ${error}`))
        this.restart()
      })

    // subscribe to all events
    myContract
      .on('*', (event: Event<any>) => {
        this.onNewEvents([event])
      })
      .on('error', (error: any) => {
        log(chalk.red(`etherjs error: ${error}`))
        this.restart()
      })
@ricmoo ricmoo added investigate Under investigation and may be a bug. on-deck This Enhancement or Bug is currently being worked on. bug Verified to be an issue. and removed investigate Under investigation and may be a bug. labels Apr 13, 2021
@ricmoo
Copy link
Member

ricmoo commented Apr 19, 2021

This has been addressed in 5.1.2. Try it out and let me know if there are any more issues.

@ricmoo ricmoo added fixed/complete This Bug is fixed or Enhancement is complete and published. and removed on-deck This Enhancement or Bug is currently being worked on. labels Apr 19, 2021
@nionis
Copy link
Author

nionis commented Apr 19, 2021

@ricmoo looks good over here, thanks!

@ricmoo
Copy link
Member

ricmoo commented Apr 19, 2021

Awesome! Glad to hear it. :)

Thanks! :)

@ricmoo ricmoo closed this as completed Apr 19, 2021
pull bot pushed a commit to shapeshift/ethers.js that referenced this issue Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published.
Projects
None yet
Development

No branches or pull requests

2 participants