Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Fix silent errors #476

Merged
merged 10 commits into from
Feb 28, 2017
Merged

Fix silent errors #476

merged 10 commits into from
Feb 28, 2017

Conversation

calebmer
Copy link
Contributor

Logs an error to the console now instead of silently ignoring errors when a user does not explicitly use the error property on our data object.

This is one of the error changes we wanted to make for AC 1.0.

Interestingly enough, this change caught a couple of bugs in our test suite 😊

cc @helfer, @martijnwalraven

  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass
  • Update CHANGELOG.md with your change

@jbaxleyiii
Copy link
Contributor

@calebmer this is great!

console.error('Uncaught (in react-apollo)', error.stack || error);
}
}, 10);
Object.defineProperty(data, 'error', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would there be any benefit in only doing this in development mode? Or is the overhead minimal enough that we should just always do it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m for always logging because:

  1. The overhead is fairly small.
  2. In production a user should really be catching the error anyway.
  3. Some error tracking libraries may report console.error exceptions.

@jbaxleyiii
Copy link
Contributor

Are console logs still slow in react native?

@calebmer
Copy link
Contributor Author

@jbaxleyiii as far as I know it’s a safe assumption that React Native logs will always be slow 😣

However, for just printing an error stack trace which is a few bytes of text I highly doubt there will be any performance impact. The real killers for logging in React Native are sophisticated logging libraries like redux-logger which dump the entire Redux before/after state on every action.

Also, users should really be expected to catch and handle these errors, so even if there is some performance impact on the rare event there is an error it is a (mostly) one time cost and it has an easy fix on the user’s part.

@jbaxleyiii
Copy link
Contributor

That makes total sense!

@calebmer
Copy link
Contributor Author

Fixed CI 👍

@helfer
Copy link
Contributor

helfer commented Feb 28, 2017

Neat! We've been talking about doing this for a while, but we never actually did it 👍

@helfer helfer merged commit a30cb83 into master Feb 28, 2017
@helfer helfer deleted the fix/silent-errors branch February 28, 2017 04:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants