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

Improve normaliseError() utility in Client class #516

Merged
merged 9 commits into from
Apr 9, 2019

Conversation

bengourley
Copy link
Contributor

@bengourley bengourley commented Apr 4, 2019

This PR makes a couple of improvements to the normaliseError() function which is used by notify() to coerce its arguments into a reasonable error, or generate an error alerting the developer to incorrect usage:

  • When dd4030b was added it meant every notify() call that ended up generating a stacktrace included a frame from this codebase. The errorFramesToSkip count has been bump to mitigate that.
  • The logic for a missing error argument has been moved so that it is all encapsulated inside this function, and in the process fixed an issue where null ended up in the "object" case block (see Generate a correct error message when null is passed to notify() #400 for original report/potential fix)

Testing

Unit tests and end-to-end tests added to cover these changes.

Bundle size discussion time

Since this makes changes to @bugsnag/core it stands to affect browser bundle size. Here's the change:

- 11.68kB
+ 11.64kB

Net decrease of 0.04kB. I think this is 🆒.

The existing logic prevented "null" from being reported correctly. This cleans up the logic and
makes sure it's all contained in the normaliseError() function.

Fixes #400.
… frames

When the change in dd4030b was applied, this should have happened but there were no tests verifying
this aspect of the notifier so the regression was not picked up. This update adds some unit and
end-to-end tests for this particular code path.
test/browser/features/handled_errors.feature Outdated Show resolved Hide resolved
packages/core/client.js Outdated Show resolved Hide resolved
@bengourley bengourley merged commit fd25dc8 into next Apr 9, 2019
@bengourley bengourley deleted the client-normalise-err-improvements branch April 9, 2019 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants