Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Manual memory testing, consoleAlert memory leak fix #300

Merged
merged 9 commits into from
Apr 7, 2017
16 changes: 8 additions & 8 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extend(Raven.prototype, {
config: function config(dsn, options) {
// We get lots of users using raven-node when they want raven-js, hence this warning if it seems like a browser
if (typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined') {
utils.consoleAlert('This looks like a browser environment; are you sure you don\'t want Raven.js for browser JavaScript? https://sentry.io/for/javascript');
utils.consoleAlertOnce('This looks like a browser environment; are you sure you don\'t want Raven.js for browser JavaScript? https://sentry.io/for/javascript');
}

if (arguments.length === 0) {
Expand Down Expand Up @@ -445,32 +445,32 @@ extend(Raven.prototype, {
// Deprecations
extend(Raven.prototype, {
getIdent: function getIdent(result) {
utils.consoleAlert('getIdent has been deprecated and will be removed in v2.0');
utils.consoleAlertOnce('getIdent has been deprecated and will be removed in v2.0');
return result;
},
captureError: function captureError() {
utils.consoleAlert('captureError has been deprecated and will be removed in v2.0; use captureException instead');
utils.consoleAlertOnce('captureError has been deprecated and will be removed in v2.0; use captureException instead');
return this.captureException.apply(this, arguments);
},
captureQuery: function captureQuery() {
utils.consoleAlert('captureQuery has been deprecated and will be removed in v2.0');
utils.consoleAlertOnce('captureQuery has been deprecated and will be removed in v2.0');
return this;
},
patchGlobal: function (cb) {
utils.consoleAlert('patchGlobal has been deprecated and will be removed in v2.0; use install instead');
utils.consoleAlertOnce('patchGlobal has been deprecated and will be removed in v2.0; use install instead');
registerExceptionHandler(this, cb);
return this;
},
setUserContext: function setUserContext() {
utils.consoleAlert('setUserContext has been deprecated and will be removed in v2.0; use setContext instead');
utils.consoleAlertOnce('setUserContext has been deprecated and will be removed in v2.0; use setContext instead');
return this;
},
setExtraContext: function setExtraContext() {
utils.consoleAlert('setExtraContext has been deprecated and will be removed in v2.0; use setContext instead');
utils.consoleAlertOnce('setExtraContext has been deprecated and will be removed in v2.0; use setContext instead');
return this;
},
setTagsContext: function setTagsContext() {
utils.consoleAlert('setTagsContext has been deprecated and will be removed in v2.0; use setContext instead');
utils.consoleAlertOnce('setTagsContext has been deprecated and will be removed in v2.0; use setContext instead');
return this;
},
});
Expand Down
4 changes: 2 additions & 2 deletions lib/middleware/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ var getClient = function (clientOrDSN) {
// Error handler. This should be the last item listed in middleware, but
// before any other error handlers.
connectMiddleware.errorHandler = function (clientOrDSN) {
utils.consoleAlert('top-level Raven.middleware.*.errorHandler has been deprecated and will be removed in v2.0; use Raven.errorHandler() instance method instead');
utils.consoleAlertOnce('top-level Raven.middleware.*.errorHandler has been deprecated and will be removed in v2.0; use Raven.errorHandler() instance method instead');
return getClient(clientOrDSN).errorHandler();
};

// Ensures asynchronous exceptions are routed to the errorHandler. This
// should be the **first** item listed in middleware.
connectMiddleware.requestHandler = function (clientOrDSN) {
utils.consoleAlert('top-level Raven.middleware.*.requestHandler has been deprecated and will be removed in v2.0; use Raven.requestHandler() instance method instead');
utils.consoleAlertOnce('top-level Raven.middleware.*.requestHandler has been deprecated and will be removed in v2.0; use Raven.requestHandler() instance method instead');
return getClient(clientOrDSN).requestHandler();
};

Expand Down
20 changes: 13 additions & 7 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ module.exports.disableConsoleAlerts = function disableConsoleAlerts() {
};

module.exports.consoleAlert = function consoleAlert(msg) {
if (consoleAlerts) {
console.log('raven@' + ravenVersion + ' alert: ' + msg);
}
};

module.exports.consoleAlertOnce = function consoleAlertOnce(msg) {
if (consoleAlerts && !(msg in consoleAlerts)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah

consoleAlerts[msg] = true;
console.log('raven@' + ravenVersion + ' alert: ' + msg);
Expand Down Expand Up @@ -135,6 +141,12 @@ function getModule(filename, base) {
return file;
}

function parseLines(lines, frame) {
frame.pre_context = lines.slice(Math.max(0, frame.lineno - (LINES_OF_CONTEXT + 1)), frame.lineno - 1);
frame.context_line = lines[frame.lineno - 1];
frame.post_context = lines.slice(frame.lineno, frame.lineno + LINES_OF_CONTEXT);
}

function parseStack(err, cb) {
var frames = [],
cache = {};
Expand Down Expand Up @@ -184,7 +196,7 @@ function parseStack(err, cb) {
}

if (frame.filename in cache) {
parseLines(cache[frame.filename]);
parseLines(cache[frame.filename], frame);
if (--callbacks === 0) cb(frames);
return;
}
Expand All @@ -198,12 +210,6 @@ function parseStack(err, cb) {
frames[index] = frame;
if (--callbacks === 0) cb(frames);
});

function parseLines(lines) {
frame.pre_context = lines.slice(Math.max(0, frame.lineno - (LINES_OF_CONTEXT + 1)), frame.lineno - 1);
frame.context_line = lines[frame.lineno - 1];
frame.post_context = lines.slice(frame.lineno, frame.lineno + LINES_OF_CONTEXT);
}
});
}

Expand Down