Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Subscription object should be returned without await #5203

@nazarhussain

Description

@nazarhussain

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Currently the user have to use await to fetch the subscription object before listening to it.

(await myContract.events.MyEvent()).on('data', console.log)

Expected Behavior

Logically this can be avoid that will make it consistent with the 1.x. We can throw error event if it fails to subscribe.

myContract.events.MyEvent().on('data', console.log).on('error', console.error); 

or

myContract.events.MyEvent().on('data', console.log).catch(console.error); 

Steps to Reproduce

Mentioned in example above.

Web3.js Version

4.x

Environment

  • Operating System:
  • Browser:
  • Node.js Version:
  • NPM Version:

Anything Else?

To make this work, we have to refactor the subscription manager. It's trivial change but not complex.

Metadata

Metadata

Assignees

Labels

4.x4.0 relatedBugAddressing a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions