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: Use JSON.stringify for [object Object] #1181

Closed
wants to merge 1 commit into from

Conversation

taylor-cedar
Copy link

@taylor-cedar taylor-cedar commented Dec 24, 2017

There are several issues about [object Object] showing up as the exception message. Obviously people should throw Error instead of a normal JS object. I think it would be way more helpful if the JS object was JSON stringified, so you could see the actual error object.

This PR changes the message -> String logic, so if it's an object, it uses JSON.stringify instead.

exceptionMessage = JSON.stringify(msg);
} else {
exceptionMessage = '' + msg;
}
Copy link
Author

Choose a reason for hiding this comment

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

Moved string convert logic before the ignore logic, so user's can ignore on custom objects

@kamilogorek
Copy link
Contributor

kamilogorek commented Jan 9, 2018

A reason why we don't do that is that when you pass a very large object, payload size can exceed 100kB which is our current limit for a single event. This will also create way too many issues in the UI, which on the other hand will create too much noise. We'll try to revisit this in the next major version.

@taylor-cedar
Copy link
Author

taylor-cedar commented Jan 13, 2018

@kamilogorek This is very useful feature for tracking down errors. Can we just put an upper limit on the JSON.stringify size? If the size it is greater than 500 characters or even 100 characters, display [object Object] or {"something": "hello" ....? There are ways to fix it while keeping under some limit.

The size issue could happen with a really long error message (or stack trace) currently. The JSON.stringify errors don't have a stack trace, so there is a lot of room in the request.

@kamilogorek
Copy link
Contributor

Hey @taylor-cedar, it'll be pulled down to Raven.js once we get this one working for Node -
getsentry/raven-node#416 :)

@kirillgroshkov
Copy link

We got around by monkey-patching the function now, but would be nice to have it merged

@liuwuhaoo
Copy link

liuwuhaoo commented Mar 5, 2018

Hi, did the #416 merge into ravenjs?

@MaxBittker
Copy link
Contributor

MaxBittker commented Mar 5, 2018

I don't believe it has yet but it would still be a good improvement we're planning to make

@MaxBittker
Copy link
Contributor

somewhat related special cases?
#360
#939

@DeadSuperHero
Copy link

Would be really great to get this functionality in raven-js; particularly in relation to [object Event] messages.

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.

None yet

6 participants