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

Fix crashes when enabledBreadcrumbTypes is null #1467

Merged
merged 4 commits into from
Jul 12, 2021

Conversation

imjoehaines
Copy link
Contributor

@imjoehaines imjoehaines commented Jul 8, 2021

Goal

Following on from #1466, this PR fixes crashes in various plugins that assumed enabledBreadcrumbTypes must always be an array. They now allow for the case where it may be null and handle it accordingly

Testing

Existing tests & new unit tests. Manually tested in browser, electron and react native projects

@imjoehaines imjoehaines changed the base branch from next to fix-auto-breadcrumbs-when-null July 8, 2021 15:31
@imjoehaines imjoehaines changed the title Fix crash when enabledBreadcrumbTypes is null Fix crashes when enabledBreadcrumbTypes is null Jul 8, 2021
@github-actions
Copy link

github-actions bot commented Jul 8, 2021

@bugsnag/browser bundle size diff

Minified Minfied + Gzipped
Before 41.31 kB 12.72 kB
After 41.33 kB 12.72 kB
± ⚠️ +12 bytes ⚠️ +6 bytes

code coverage diff

Ok File Lines Branches Functions Statements
/home/runner/work/bugsnag-js/bugsnag-js/packages/core/client.js 99.34%
(+0%)
97.62%
(+0.06%)
100%
(+0%)
98.8%
(+0.01%)
🔴 /home/runner/work/bugsnag-js/bugsnag-js/packages/electron/src/client/renderer.js 34.38%
(-1.1%)
0%
(+0%)
0%
(+0%)
30.56%
(-0.87%)
/home/runner/work/bugsnag-js/bugsnag-js/packages/plugin-electron-ipc/bugsnag-ipc-main.js 82.54%
(+0%)
75%
(+1.92%)
89.47%
(+0%)
81.43%
(+0%)
/home/runner/work/bugsnag-js/bugsnag-js/packages/plugin-electron-net-breadcrumbs/net-breadcrumbs.js 100%
(+0%)
90%
(+2.5%)
100%
(+0%)
100%
(+0%)
🔴 /home/runner/work/bugsnag-js/bugsnag-js/packages/react-native/src/notifier.js 72.15%
(+0.36%)
61.76%
(-0.74%)
61.54%
(+0%)
71.26%
(+0.33%)

Total:

Lines Branches Functions Statements
82.26%(-0.01%) 71.55%(+0.07%) 83.47%(+0%) 81.2%(-0.01%)

Generated by 🚫 dangerJS against 341d6c7

@imjoehaines imjoehaines force-pushed the fix-crash-when-enabled-breadcrumb-types-is-null branch 2 times, most recently from 6884c1f to 5a27300 Compare July 9, 2021 09:13
@imjoehaines imjoehaines force-pushed the fix-crash-when-enabled-breadcrumb-types-is-null branch from caa707a to 0943969 Compare July 9, 2021 13:59
@imjoehaines imjoehaines marked this pull request as ready for review July 12, 2021 08:05
Copy link
Contributor

@kattrali kattrali left a comment

Choose a reason for hiding this comment

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

Is it possible to either:

  • Coerce enabledBreadcrumbTypes to always be an array during config validation (where null -> all)? or
  • Add a helper on config to handle the null check? Most of the validation checks now are of the form if (config.breadcrumbTypes !== null && config.breadcrumbTypes.contain(type)) where maybe it could be something like if (config.isBreadcrumbTypeEnabled(type))

Trying to think of a way to prevent this kind of issue going forward since every future plugin/consumer of this config option basically needs to have this check. Stronger type validation on our part? Additional linting?

@imjoehaines imjoehaines force-pushed the fix-crash-when-enabled-breadcrumb-types-is-null branch from 0943969 to 341d6c7 Compare July 12, 2021 09:53
@imjoehaines
Copy link
Contributor Author

Trying to think of a way to prevent this kind of issue going forward since every future plugin/consumer of this config option basically needs to have this check. Stronger type validation on our part? Additional linting?

I avoided doing anything extra in core to try to avoid increasing the browser bundle size, but it turns out that a helper method actually saves space because it removes duplication from plugins

I've opened #1468 for this as it affects files in this PR, #1466 and files that weren't touched by either PR

Base automatically changed from fix-auto-breadcrumbs-when-null to next July 12, 2021 14:34
@imjoehaines imjoehaines merged commit 17e4f34 into next Jul 12, 2021
@imjoehaines imjoehaines deleted the fix-crash-when-enabled-breadcrumb-types-is-null branch July 12, 2021 14:34
@djskinner djskinner mentioned this pull request Jul 26, 2021
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.

2 participants