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

Error handling #370

Closed
1 task done
cjorasch opened this issue Dec 19, 2017 · 13 comments
Closed
1 task done

Error handling #370

cjorasch opened this issue Dec 19, 2017 · 13 comments

Comments

@cjorasch
Copy link

Stencil version:

I'm submitting a:

  • feature request

Current behavior:
If an Error is thrown anywhere within a component's render() method then the app will be in an inconsistent state. One significant impact is that router navigation no longer works.

Expected behavior:
Stencil should wrap calls to the render() method in a try/catch so that it can correctly handle the resulting state. It looks like try/catch is being done at a higher level but maybe some of the error handling isn't working.

Other component methods such as PropDidChange() andComponentDidLoad() may have similar issues.

Further enhancements:

Beyond catching Errors it would be nice to be able to define UI behavior for error conditions. This could include not only errors in component code but also errors encountered by Stencil (e.g. component js file failed to load because of network error).

Since components are loaded async it would also be nice to have more control over display during loading. It can be confusing to see a blank screen (or blank section of the screen) and not know that there is some activity in progress. Async component loading could take multiple seconds over poor networks.

One example of error handling is React Error Boundaries.

@adamdbradley
Copy link
Contributor

Yeah good idea, I think we can improve how we are catching errors. Thanks for the feedback.

@adamdbradley
Copy link
Contributor

@cjorasch in the 0.2.0-1 release we made some error handling improvements. Would you be able to test it out and see if it works as expected?

@cjorasch
Copy link
Author

I tried version 0.2.0-1 and still run into the same problem.

@adamdbradley
Copy link
Contributor

Which methods are having the issue?

@cjorasch
Copy link
Author

I navigate to a page that will throw an error. I throw an Error during page render and get a blank page. After the error, if I navigate back to a prior page that previously rendered correctly and then it does not render. Everything is blank until I refresh the page. Possibly an issue within the router.

@dxetech
Copy link

dxetech commented Jun 4, 2018

@adamdbradley Is there any way to log or catch errors? Your commit fixes the issue that @cjorasch originally submitted, but I don't see where to capture these errors.

I am using the component starter, and would like to log to a bug capturing web service for both expected an unexpected issues (e.g. sentry.io)

@felschr
Copy link

felschr commented Jul 18, 2018

I'm having the same issue as @dxetech.
I have to add try catch blocks everywhere in my components just to find out where and what error occurs.
Some kind of global error handling or flag for logging errors would be nice.

@amazzoccone
Copy link

Isn't an important improvement this issue? It's a really bad experience see a blank page 😞.

@dxetech
Copy link

dxetech commented Nov 21, 2018

We have determined that this issue has left Stencil as not production ready for our environment. If we cannot trace and capture bugs and exceptions, we cannot rely on Stencil.

It's a shame, because we love everything that Stencil represents, and believe in Web Components and TypeScript as the future of the web, but this simple issue is too critical for us to ignore.

@mnemanja
Copy link

mnemanja commented Jan 8, 2020

Why was this issue closed? Has there been a solution devised on how to handle errors?

@Chibionos
Copy link

Reopen this issue please, it is critical for error handling to be integrated in the framework. Without which we cannot add insights to figure out if we are hitting errors on the wild.

@johnjenkins
Copy link
Contributor

@Chibionos perhaps give this PR a +1. It enables better error handling in things like ‘render’

@splitinfinities
Copy link
Contributor

Hey folks! Like @johnjenkins suggests, please head over there so we can gather signal around a feature like this!

@ionic-team ionic-team locked and limited conversation to collaborators Nov 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants