Search code examples
javascriptuglifyjsuglifier

JS Compression issues - callback called twice when using uglifier


Got the following code

import Rails from 'rails-ujs'
import _ from 'underscore'

export default class Ajax {
  static post(url, payload, success, error = () => {}, context = {}) {
    Rails.ajax({
      url: url,
      data: payload,
      type: 'post',
      success: success.bind(context),
      error: error.bind(context)
    })
  }
}

the post method works as expected on dev env, once code gets minified, success callback is called twice per one call. How can I understand why it happens ?

I'm 99% sure this is the issue, cause If I wrap the success.bind with _.once, callback is called only once.

Using uglifier gem version 4.1.20 with harmony:true option


Solution

  • https://github.com/getsentry/sentry-javascript/issues/2340

    Sentry issue, be aware, not related to compression, just not use sentry on dev..