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

Manually triggered listener throws error even if catched #10873

Closed
mediafreakch opened this issue Nov 28, 2019 · 1 comment
Closed

Manually triggered listener throws error even if catched #10873

mediafreakch opened this issue Nov 28, 2019 · 1 comment

Comments

@mediafreakch
Copy link

@mediafreakch mediafreakch commented Nov 28, 2019

Version

2.6.10

Reproduction link

https://codesandbox.io/s/button-that-awaits-async-click-listener-in-vuejs-m3hz1

Steps to reproduce

  1. Open the codebox.io console window
  2. Click the button in the demo panel and observe the console

What is expected?

The error should not be thrown. No warning message should be emitted.

What is actually happening?

Error is thrown and a warning message is emitted.


The important code can be found in /components/VButton.vue on line 36 and following

@posva

This comment has been minimized.

Copy link
Member

@posva posva commented Nov 28, 2019

It may look confusing in this specific situation, but the error handling is added at App level since that's where it would be called usually via the @click event listener but we cannot predict that the listener is going to get called inside the component so we wrap the method call to make sure we can trace the errors. If we don't wrap it, your code would work but it would not trace errors for most users.
One way to get around this is by passing the method as a prop

@posva posva closed this Nov 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.