rollbar / rollbar.js

Error tracking and logging from Javascript to Rollbar

Home Page:https://docs.rollbar.com/docs/javascript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't send the error object

robbporto opened this issue · comments

Using the latest Rollbar JS library, I'm trying to send a error object like this:

Rollbar.error(new Error("something went wrong"))

According to the docs, this should be working but it is not.

Is this in this in the browser, on Node.js, or something else? Have you initialized Rollbar in any of the ways described here?

At the least, you will need to initialize with an access token.

@waltjones, Rollbar is initialized (when I send Rollbar.info it just works), the problem happens when I send an error object. If I send an error string (Rollbar.error("test 123")), it works.

Got it.

I tested this in browser (Chrome/Ubuntu) with no issue: rollbar.error(new Error('log error'))

I'm currently testing on Rollbar.js v2.22.0, but this is a standard test case and has been tested on earlier versions as well.

You're not transpiling to or from something unusual or worth mentioning? Or a specific browser?

Nothing that I can think of... We have a Rails app.

We are calling Rollbar when loading the page and then setting the Rollbar configs in the window object. I'm testing with Google Chrome.

I confirmed on Rails 6.0.3.6, which defaults to the webpacker js bundle instead of sprockets, that adding the specific syntax in application.js works. Maybe a transpiler (e.g. babel) would do something unexpected, and while that may still be true, the default setup does not.

Given a Rails app and modern browser, anywhere Rollbar.info or Rollbar.error('string') works, the only logical difference when passing an error object is the error object as an argument to rollbar.log() which handles everything internally in Rollbar.js. This logic hasn't changed recently and I wouldn't expect to see only this case fail.

For now, I don't have insight about what's different in your setup, or what would affect this one thing. Does it make a difference if you throw and then pass the caught error? Also, I assume nothing odd shows up in the dev console?

Feel free to share specific rails version, webpacker or sprockets config, etc. If it's possible to set up some kind of minimal test/repro, I'm happy to take a look at that.

I'm gonna do more tests here today. I'm experimenting with the React Rollbar library (https://github.com/rollbar/rollbar-react) but SourceMaps are not working.

I'm closing this issue for now and reopening if I find something new.

Thank you for your help!