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

Errors are not reported from hooks #447

Closed
matthewjumpsoffbuildings opened this issue Sep 26, 2019 · 3 comments
Closed

Errors are not reported from hooks #447

matthewjumpsoffbuildings opened this issue Sep 26, 2019 · 3 comments
Labels
@barba/core bug hacktoberfest Hacktoberfest® event - https://hacktoberfest.digitalocean.com

Comments

@matthewjumpsoffbuildings

When some dodgy code is inside a Views beforeLeave() function for example, the console doesnt show an error, instead the URL changes, but the page doesnt update

Im using Chrome 77, MacOS 10.14.3

I created a minimal reproduction repo here: https://github.com/matthewjumpsoffbuildings/barba-issue

Chuck it in a local dev environment like valet and browse to the index html, click the About link. If you look in src/app.js you'll see the views have a call to a non-existent function SOME_BROKEN_STUFF(), but no console error appears, the URL updates, but the DOM doesnt change.

@xavierfoucrier
Copy link
Member

Hi @matthewjumpsoffbuildings,

Sorry for the late reply, I will dig into that next week and give a feedback 😉

@xavierfoucrier
Copy link
Member

Hi @matthewjumpsoffbuildings,

This is probably because it's Promise based when hooks are chained and triggered, a simple Promise catch should do the trick.

https://github.com/barbajs/barba/blob/master/packages/core/src/hooks.ts#L113

After cloning your repo, it appear that no error are thrown since the debug mode is not properly set to true with the appropriate logLevel:

barba.init({
  debug: true,
  logLevel: 'error',
  views: ...
});

https://barba.js.org/docs/v2/user/core.html#debug

Finally, you can also do a simple try/catch, but yeah, errors should appear by them self...

I will mark this as bug and wait for @thierrymichel opinion.
Thanks again for the catch 😉

@xavierfoucrier xavierfoucrier changed the title Errors not reported from View functions Errors are not reported from hooks Oct 9, 2019
@xavierfoucrier xavierfoucrier added the hacktoberfest Hacktoberfest® event - https://hacktoberfest.digitalocean.com label Oct 22, 2019
@matthewjumpsoffbuildings
Copy link
Author

I see this is closed, has this been resolved, or is it just being closed to keep the issues tidy?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@barba/core bug hacktoberfest Hacktoberfest® event - https://hacktoberfest.digitalocean.com
Projects
None yet
Development

No branches or pull requests

2 participants