rollbar-gem icon indicating copy to clipboard operation
rollbar-gem copied to clipboard

v3.3.1 - Causes breaking change - RollbarJS no longer loading

Open ro-savage opened this issue 3 years ago • 5 comments

We upgraded from v3.3.0 to v3.3.1 and this caused the rollbar js to stop being loaded by Rails (that is the embed script is never added).

Reverting to v3.3.0 solved this.

We get this error in our logs

E, [2022-07-17T23:25:26.700460 #25] ERROR -- : [364578a8-5ed5-4186-8bda-d4cc5f59f7b7] [Rollbar] Rollbar.js could not be added because uninitialized constant Rollbar::JSON::JsOptionsState exception

It appears to have been introduced by @waltjones in https://github.com/rollbar/rollbar-gem/pull/1089

For reference, your rollbar.rb file looks like

if defined? Rollbar
  Rollbar.configure do |config|
    config.access_token = ENV['ROLLBAR_ACCESS_TOKEN']

    config.enabled = false if Rails.env.test?

    config.js_enabled = true
    config.js_options = {
      accessToken: ENV['ROLLBAR_ACCESS_TOKEN'],
      captureUncaught: true,
      payload: {
        environment: ENV['ROLLBAR_ENV'] || Rails.env
      },
      autoInstrument: {
        contentSecurityPolicy: true,
        errorOnContentSecurityPolicy: true
      }
    }

    config.person_username_method = 'account_name'
    config.person_email_method = 'email'

    config.custom_data_method = -> { { account: defined?(current_account) ? current_account.unique_id : 'unknown' } }
    config.exception_level_filters['ActionController::RoutingError'] = 'ignore'
    config.environment = ENV['ROLLBAR_ENV'] || Rails.env
    config.scrub_fields |= ['sess', '__Host-sess']
  end
end


ro-savage avatar Jul 18 '22 00:07 ro-savage

Try to change from:

config.js_options = {
      accessToken: ENV['ROLLBAR_ACCESS_TOKEN']

To:

config.js_options = {
      accessToken: ENV['POST_CLIENT_ITEM_TOKEN']

You can find post client item token in your rollbar interface

nsennickov avatar Jul 20 '22 16:07 nsennickov

Same problem here, with an almost vanilla config.

config.js_enabled = true
config.js_options = {
  accessToken: ENV["ROLLBAR_POST_CLIENT_ITEM_ACCESS_TOKEN"],
  captureUncaught: true,
  payload: {
  environment: config.environment
}

Reverting to 3.3.0 makes it work again.

jeremiemv avatar Aug 09 '22 23:08 jeremiemv

I think I've tracked this down.

In line 144 of lib/rollbar/middleware/js.rb, it calls Rollbar::JSON::JsOptionsState.new, in my environment (Ruby 3.1.0, Rails 6.1.6.1), this throws with a NameError because it can't find the constant.

scottb avatar Aug 19 '22 21:08 scottb

We just noticed this recently, as we haven't been getting js errors in a while when we should have been.

You can add require 'rollbar/middleware/js/json_value' to the top of config/initializers/rollbar.rb for the time being.

ioev avatar Sep 13 '22 16:09 ioev

Here is the exact line (with rev) that @scottb found this problem to be: https://github.com/rollbar/rollbar-gem/compare/v3.3.0...v3.3.1#diff-d5202929c8268c54895def2587ba3efc829245c433997334366a16462d57bad7R144

(We have the issue too and are rolling back).

hlascelles avatar Sep 15 '22 16:09 hlascelles

Hello Rollbar team, is there an option to fix it somehow/revert changes causing this issue and put it in the newest release? As the users of this gem wanting to keep up-to-date with the changes, we don't have an option to use one important feature of Rollbar this way - the feature convincing some of us to use higher plans or paying more (because of higher limits of handled occurrences), I don't know how is it possible such problem has not been fixed/noticed by Rollbar for 3 months?!

mateuszgorniak avatar Oct 18 '22 07:10 mateuszgorniak

@waltjones could you look at it? 🥺

mateuszgorniak avatar Nov 21 '22 13:11 mateuszgorniak

Apologies for the delay. Will have an update out asap.

waltjones avatar Dec 07 '22 18:12 waltjones

This fix is released in v3.3.3.

waltjones avatar Dec 20 '22 14:12 waltjones

Thanks @waltjones

jeremiemv avatar Dec 20 '22 17:12 jeremiemv