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

[Fixes #269] get rid of rollbar wrapper stack frames #335

Merged
merged 2 commits into from
Jul 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/browser/globalSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function _extendListenerPrototype(handler, prototype, shim) {
oldRemoveEventListener = oldRemoveEventListener._rollbarOldRemove;
}
var removeFn = function(event, callback, bubble) {
oldRemoveEventListener.call(this, event, callback && callback._wrapped || callback, bubble);
oldRemoveEventListener.call(this, event, callback && callback._rollbar_wrapped || callback, bubble);
};
removeFn._rollbarOldRemove = oldRemoveEventListener;
removeFn.belongsToShim = shim;
Expand Down
10 changes: 5 additions & 5 deletions src/browser/rollbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ Rollbar.prototype.wrap = function(f, context) {
return f;
}

if (!f._wrapped) {
f._wrapped = function () {
if (!f._rollbar_wrapped) {
f._rollbar_wrapped = function () {
try {
return f.apply(this, arguments);
} catch(exc) {
Expand All @@ -274,18 +274,18 @@ Rollbar.prototype.wrap = function(f, context) {
}
};

f._wrapped._isWrap = true;
f._rollbar_wrapped._isWrap = true;

if (f.hasOwnProperty) {
for (var prop in f) {
if (f.hasOwnProperty(prop)) {
f._wrapped[prop] = f[prop];
f._rollbar_wrapped[prop] = f[prop];
}
}
}
}

return f._wrapped;
return f._rollbar_wrapped;
} catch (e) {
// Return the original function if the wrap fails.
return f;
Expand Down
14 changes: 7 additions & 7 deletions src/browser/shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function setupShim(window, options) {
return window[alias];
}

window._rollbarShims = {};
window._rollbarShims = {};
window._rollbarWrappedError = null;

var handler = new Rollbar(options);
Expand Down Expand Up @@ -129,8 +129,8 @@ Shim.prototype.wrap = function(f, context) {
return f;
}

if (!f._wrapped) {
f._wrapped = function () {
if (!f._rollbar_wrapped) {
f._rollbar_wrapped = function () {
try {
return f.apply(this, arguments);
} catch(exc) {
Expand All @@ -146,18 +146,18 @@ Shim.prototype.wrap = function(f, context) {
}
};

f._wrapped._isWrap = true;
f._rollbar_wrapped._isWrap = true;

if (f.hasOwnProperty) {
for (var prop in f) {
if (f.hasOwnProperty(prop)) {
f._wrapped[prop] = f[prop];
f._rollbar_wrapped[prop] = f[prop];
}
}
}
}

return f._wrapped;
return f._rollbar_wrapped;
} catch (e) {
// Return the original function if the wrap fails.
return f;
Expand All @@ -173,7 +173,7 @@ function stub(method) {
});
}

var _methods =
var _methods =
'log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleUnhandledRejection'.split(',');

for (var i = 0; i < _methods.length; ++i) {
Expand Down
3 changes: 3 additions & 0 deletions src/browser/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ function addBodyTrace(item, options, callback) {
method: (!stackFrame.func || stackFrame.func === '?') ? '[anonymous]' : stackFrame.func,
colno: stackFrame.column
};
if (frame.method && frame.method.endsWith && frame.method.endsWith('._rollbar_wrapped')) {
continue;
}

code = pre = post = null;
contextLength = stackFrame.context ? stackFrame.context.length : 0;
Expand Down