-
Notifications
You must be signed in to change notification settings - Fork 5k
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
UnhandledPromiseRejectionWarning when sending a transaction and the error event handler throws #3708
Comments
gabmontes
added a commit
to bloq/web3.js
that referenced
this issue
Sep 3, 2020
Since the event handlers are run syncronously, if an `error` event handler thows, the error will return to the lib and keep the promise chain broken, rising an unhandled promise rejection error. Resolves web3#3708
14 tasks
gabmontes
added a commit
to bloq/web3.js
that referenced
this issue
Sep 3, 2020
Since the event handlers are run syncronously, if an `error` event handler thows, the error will return to the lib and keep the promise chain broken, rising an unhandled promise rejection error. Resolves web3#3708
Thanks for reporting this and opening a pr! I'll take a look at this later today 😊 |
gabmontes
added a commit
to bloq/web3.js
that referenced
this issue
Oct 15, 2020
Since the event handlers are run syncronously, if an `error` event handler thows, the error will return to the lib and keep the promise chain broken, rising an unhandled promise rejection error. Resolves web3#3708
gabmontes
added a commit
to bloq/web3.js
that referenced
this issue
Oct 16, 2020
Since the event handlers are run syncronously, if an `error` event handler thows, the error will return to the lib and keep the promise chain broken, rising an unhandled promise rejection error. Resolves web3#3708
gabmontes
added a commit
to bloq/web3.js
that referenced
this issue
Oct 19, 2020
Since the event handlers are run syncronously, if an `error` event handler thows, the error will return to the lib and keep the promise chain broken, rising an unhandled promise rejection error. Resolves web3#3708
Closed
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected behavior
Send a transaction that will fail i.e. because the gas amount is not specified, and use the events interface of the promi-event. If the
error
event handler throws, that error should be handled exclusively in "userland". If the promises interface is used as well, the no-gas-specified error should be seen.Actual behavior
An unhandled promise rejection is thrown within web3. On top of that, the error coming into the
.catch()
is not the original gas error but the error within the buggyerror
event handler. This is misleading because the issue is not within the library but in the user code and the error obtained shadows the actual send transaction error.Spoiler alert
The following line must be wrapped in a try-catch block to prevent the error to bubble up and wreak havoc:
https://github.com/ethereum/web3.js/blob/87e668275ac7d9b8af7c909137fc0626c3866929/packages/web3-core-method/src/index.js#L732
Steps to reproduce the behavior
Logs
Environment
web3@1.2.11
The text was updated successfully, but these errors were encountered: