rollbar / rollbar.js

Error tracking and logging from Javascript to Rollbar
https://docs.rollbar.com/docs/javascript
MIT License
571 stars 213 forks source link

fix: Handle the formatting of array arguments #1139

Open dentuzhik opened 5 months ago

dentuzhik commented 5 months ago

Description of the change

We are using rollbar.js in our application, and because of internal monkey-patching of console.warn some instances of invariants triggered by apollo-client crash rollbar and our application as a result.

When apollo-client logs those invariants via console.warn it has some of the arguments specified as array of objects, which get through the formatArgsAsString inside rollbar, which does not really handle arrays anyhow and crashes.

This change adds graceful handling of the arrays via a simple recursive call, trimming the array to the first 10 items not to cause any significant overhead on processing.

Type of change

Related issues

Shortcut stories and GitHub issues (delete irrelevant)

Checklists

Development

Code review

dentuzhik commented 5 months ago

@waltjones @mudetroit apologies for tagging directly, I would appreciate if we can review this and draft a new patch release.

This issue causing a crash for us in production, the backup plan so far is to go through publishing an internal fork via private registry package, but we would still want to switch back to public version.