Skip to content

Commit 28b1616

Browse files
rexxarskamilogorek
authored andcommitted
fix: dont throw exception when called captureException without config phase
1 parent b54fdf2 commit 28b1616

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

lib/client.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,12 @@ extend(Raven.prototype, {
216216
}
217217

218218
var domainContext = (domain.active && domain.active.sentryContext) || {};
219-
kwargs.user = extend({}, this._globalContext.user, domainContext.user, kwargs.user);
220-
kwargs.tags = extend({}, this._globalContext.tags, domainContext.tags, kwargs.tags);
221-
kwargs.extra = extend(
222-
{},
223-
this._globalContext.extra,
224-
domainContext.extra,
225-
kwargs.extra
226-
);
219+
var globalContext = this._globalContext || {};
220+
kwargs.user = extend({}, globalContext.user, domainContext.user, kwargs.user);
221+
kwargs.tags = extend({}, globalContext.tags, domainContext.tags, kwargs.tags);
222+
kwargs.extra = extend({}, globalContext.extra, domainContext.extra, kwargs.extra);
227223
kwargs.breadcrumbs = {
228-
values: domainContext.breadcrumbs || this._globalContext.breadcrumbs || []
224+
values: domainContext.breadcrumbs || globalContext.breadcrumbs || []
229225
};
230226

231227
/*
@@ -237,13 +233,13 @@ extend(Raven.prototype, {
237233
parseUser returns a partial kwargs object with a `request` property and possibly a `user` property
238234
*/
239235
kwargs.request = this._createRequestObject(
240-
this._globalContext.request,
236+
globalContext.request,
241237
domainContext.request,
242238
kwargs.request
243239
);
244240
if (Object.keys(kwargs.request).length === 0) {
245241
var req = this._createRequestObject(
246-
this._globalContext.req,
242+
globalContext.req,
247243
domainContext.req,
248244
kwargs.req
249245
);
@@ -265,7 +261,7 @@ extend(Raven.prototype, {
265261
kwargs.logger = kwargs.logger || this.loggerName;
266262
kwargs.event_id = eventId;
267263
kwargs.timestamp = new Date().toISOString().split('.')[0];
268-
kwargs.project = this.dsn.project_id;
264+
kwargs.project = this.dsn && this.dsn.project_id;
269265
kwargs.platform = 'node';
270266
kwargs.release = this.release;
271267

test/raven.client.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,12 @@ describe('raven.Client', function() {
373373
}
374374
});
375375
});
376+
377+
it('should call callback even without a config', function(done) {
378+
raven.captureException(new Error('wtf?'), function(err) {
379+
done();
380+
});
381+
});
376382
});
377383

378384
describe('#install()', function() {

0 commit comments

Comments
 (0)