question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Settings when used as a module not honored

See original GitHub issue

The docs state:

In situations where Bugsnag is not in its own script tag, you can set this with:

Bugsnag.autoNotify = false;

However bugsnag does all the patching which is contingent on this being true (the default) before the value can actually be set — it seems it is only actually possible to control this behavior if you inject bugsnag via a script element. Since the main reason to disable autoNotify is to prevent overzealous patching of performance sensitive functions like requestAnimationFrame, it becomes necessary to do things like:

const raf = window.requestAnimationFrame;
const bugsnag = require('bugsnag');
window.requestAnimationFrame = raf;

Rather awkward! Plus, if you aren’t concerned with stuff like IE6 support, all of the various mutations of the global space seem pointless. Why is this patching enabled by default, why isn’t it disclosed in the documentation, and why do the docs state that autoNotify can be meaningfully set this way?


This is what I came up with BTW for anybody else trying to use bugsnag without the global decoration. In my case I actually do want bugsnag to register an onerror handler, but I don’t want it to do all the wrapping. This module needs to be imported prior to bugsnag and its exported function needs to be invoked afterwards:


const restorations = [
  [ 'ApplicationCache',          'prototype', 'addEventListener' ],
  [ 'AudioTrackList',            'prototype', 'addEventListener' ],
  [ 'ChannelMergerNode',         'prototype', 'addEventListener' ],
  [ 'CryptoOperation',           'prototype', 'addEventListener' ],
  [ 'EventSource',               'prototype', 'addEventListener' ],
  [ 'EventTarget',               'prototype', 'addEventListener' ],
  [ 'FileReader',                'prototype', 'addEventListener' ],
  [ 'HTMLUnknownElement',        'prototype', 'addEventListener' ],
  [ 'IDBDatabase',               'prototype', 'addEventListener' ],
  [ 'IDBRequest',                'prototype', 'addEventListener' ],
  [ 'IDBTransaction',            'prototype', 'addEventListener' ],
  [ 'KeyOperation',              'prototype', 'addEventListener' ],
  [ 'MediaController',           'prototype', 'addEventListener' ],
  [ 'MessagePort',               'prototype', 'addEventListener' ],
  [ 'ModalWindow',               'prototype', 'addEventListener' ],
  [ 'Node',                      'prototype', 'addEventListener' ],
  [ 'Notification',              'prototype', 'addEventListener' ],
  [ 'requestAnimationFrame' ],
  [ 'Screen',                    'prototype', 'addEventListener' ],
  [ 'setImmediate' ],
  [ 'setInterval' ],
  [ 'setTimeout' ],
  [ 'SVGElementInstance',        'prototype', 'addEventListener' ],
  [ 'TextTrack',                 'prototype', 'addEventListener' ],
  [ 'TextTrackCue',              'prototype', 'addEventListener' ],
  [ 'TextTrackList',             'prototype', 'addEventListener' ],
  [ 'WebSocket',                 'prototype', 'addEventListener' ],
  [ 'WebSocketWorker',           'prototype', 'addEventListener' ],
  [ 'Window',                    'prototype', 'addEventListener' ],
  [ 'Worker',                    'prototype', 'addEventListener' ],
  [ 'XMLHttpRequest',            'prototype', 'addEventListener' ],
  [ 'XMLHttpRequestEventTarget', 'prototype', 'addEventListener' ],
  [ 'XMLHttpRequestUpload',      'prototype', 'addEventListener' ],
].map(path => {
  const values = [ window ];

  for (const key of path) {
    if (values[0].hasOwnProperty(key)) {
      values.unshift(values[0][key]);
    } else {
      return;
    }
  }

  const [ value, target ] = values;
  const key = path.pop();

  return () => target[key] = value;
}).filter(Boolean);

export default () => restorations.forEach(restore => restore());

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
kattralicommented, Jul 4, 2017

Thanks for the report, @bathos. It sounds like a rethinking of a lot of this logic (and workarounds) is needed, especially to put users in better control of which browsers they care about. I’m updating the roadmap to ensure this is addressed soon.

1reaction
bathoscommented, Nov 23, 2017

The update sounds fantastic! I happen to be working on a project that isn’t in prod yet so it’s a perfect time for me to do some test driving.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module Not Found Error: No module named config
If you are using Python 3, run the following to install config . sudo pip3 install config.
Read more >
'Use module on all pages' setting not working for new or
When I check the checkbox for the setting 'Use module on all pages', the module is visible on all current pages, witch is...
Read more >
Django Tips #20 Working With Multiple Settings Modules
Basic Structure. First thing we want to do is to create a folder named settings , rename the settings.py file to base.py and...
Read more >
Custom Module Configuration not working - Drupal Answers
I have the following file. modules/custom/test_module/config/install/test_module.settings.yml. test_module.settings: message: 'Hello' ...
Read more >
How to Use Go Modules
The first thing to do is decide the directory the module will live in. With the introduction of Go modules, it became possible...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found