@honeybadger-io/js 6.3.0 → 6.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/honeybadger.js +163 -72
- package/dist/browser/honeybadger.js.map +1 -1
- package/dist/browser/honeybadger.min.js +1 -1
- package/dist/browser/honeybadger.min.js.map +1 -1
- package/dist/server/honeybadger.js +245 -127
- package/dist/server/honeybadger.js.map +1 -1
- package/dist/server/integrations/uncaught_exception_monitor.d.ts +17 -0
- package/dist/server/integrations/{uncaught_exception.d.ts → uncaught_exception_plugin.d.ts} +1 -1
- package/package.json +3 -3
|
@@ -296,6 +296,9 @@ var require$$0 = /*@__PURE__*/getAugmentedNamespace(stackTraceParser_esm);
|
|
|
296
296
|
function makeBacktrace(stack, filterHbSourceCode, logger) {
|
|
297
297
|
if (filterHbSourceCode === void 0) { filterHbSourceCode = false; }
|
|
298
298
|
if (logger === void 0) { logger = console; }
|
|
299
|
+
if (!stack) {
|
|
300
|
+
return [];
|
|
301
|
+
}
|
|
299
302
|
try {
|
|
300
303
|
var backtrace = stackTraceParser
|
|
301
304
|
.parse(stack)
|
|
@@ -412,14 +415,20 @@ var require$$0 = /*@__PURE__*/getAugmentedNamespace(stackTraceParser_esm);
|
|
|
412
415
|
}
|
|
413
416
|
exports.getSourceForBacktrace = getSourceForBacktrace;
|
|
414
417
|
function runBeforeNotifyHandlers(notice, handlers) {
|
|
418
|
+
var results = [];
|
|
415
419
|
var result = true;
|
|
416
420
|
for (var i = 0, len = handlers.length; i < len; i++) {
|
|
417
421
|
var handler = handlers[i];
|
|
418
|
-
|
|
422
|
+
var handlerResult = handler(notice);
|
|
423
|
+
if (handlerResult === false) {
|
|
419
424
|
result = false;
|
|
420
425
|
}
|
|
426
|
+
results.push(handlerResult);
|
|
421
427
|
}
|
|
422
|
-
return
|
|
428
|
+
return {
|
|
429
|
+
results: results,
|
|
430
|
+
result: result
|
|
431
|
+
};
|
|
423
432
|
}
|
|
424
433
|
exports.runBeforeNotifyHandlers = runBeforeNotifyHandlers;
|
|
425
434
|
function runAfterNotifyHandlers(notice, handlers, error) {
|
|
@@ -808,6 +817,42 @@ var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
|
|
|
808
817
|
};
|
|
809
818
|
return __assign.apply(this, arguments);
|
|
810
819
|
};
|
|
820
|
+
var __awaiter$1 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
821
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
822
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
823
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
824
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
825
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
826
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
827
|
+
});
|
|
828
|
+
};
|
|
829
|
+
var __generator$1 = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
|
|
830
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
831
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
832
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
833
|
+
function step(op) {
|
|
834
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
835
|
+
while (_) try {
|
|
836
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
837
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
838
|
+
switch (op[0]) {
|
|
839
|
+
case 0: case 1: t = op; break;
|
|
840
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
841
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
842
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
843
|
+
default:
|
|
844
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
845
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
846
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
847
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
848
|
+
if (t[2]) _.ops.pop();
|
|
849
|
+
_.trys.pop(); continue;
|
|
850
|
+
}
|
|
851
|
+
op = body.call(thisArg, _);
|
|
852
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
853
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
854
|
+
}
|
|
855
|
+
};
|
|
811
856
|
Object.defineProperty(client, "__esModule", { value: true });
|
|
812
857
|
client.Client = void 0;
|
|
813
858
|
var util_1$4 = util$1;
|
|
@@ -826,7 +871,7 @@ var Client = /** @class */ (function () {
|
|
|
826
871
|
this.__notifier = {
|
|
827
872
|
name: '@honeybadger-io/core',
|
|
828
873
|
url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/core',
|
|
829
|
-
version: '6.
|
|
874
|
+
version: '6.4.1'
|
|
830
875
|
};
|
|
831
876
|
this.config = __assign({ apiKey: null, endpoint: 'https://api.honeybadger.io', environment: null, hostname: null, projectRoot: null, component: null, action: null, revision: null, reportData: null, breadcrumbsEnabled: true, maxBreadcrumbs: 40, maxObjectDepth: 8, logger: console, developmentEnvironments: ['dev', 'development', 'test'], debug: false, tags: null, enableUncaught: true, enableUnhandledRejection: true, afterUncaught: function () { return true; }, filters: ['creditcard', 'password'], __plugins: [] }, opts);
|
|
832
877
|
this.__initStore();
|
|
@@ -839,6 +884,13 @@ var Client = /** @class */ (function () {
|
|
|
839
884
|
Client.prototype.getNotifier = function () {
|
|
840
885
|
return this.__notifier;
|
|
841
886
|
};
|
|
887
|
+
/**
|
|
888
|
+
* CAREFUL: When adding a new notifier or updating the name of an existing notifier,
|
|
889
|
+
* the Honeybadger rails project may need its mappings updated.
|
|
890
|
+
* See https://github.com/honeybadger-io/honeybadger/blob/master/app/presenters/breadcrumbs_presenter.rb
|
|
891
|
+
* https://github.com/honeybadger-io/honeybadger/blob/master/app/models/parser/java_script.rb
|
|
892
|
+
* https://github.com/honeybadger-io/honeybadger/blob/master/app/models/language.rb
|
|
893
|
+
**/
|
|
842
894
|
Client.prototype.setNotifier = function (notifier) {
|
|
843
895
|
this.__notifier = notifier;
|
|
844
896
|
};
|
|
@@ -887,81 +939,26 @@ var Client = /** @class */ (function () {
|
|
|
887
939
|
var _this = this;
|
|
888
940
|
if (name === void 0) { name = undefined; }
|
|
889
941
|
if (extra === void 0) { extra = undefined; }
|
|
890
|
-
var preConditionError = null;
|
|
891
942
|
var notice = this.makeNotice(noticeable, name, extra);
|
|
892
|
-
if (!notice) {
|
|
893
|
-
this.logger.debug('failed to build error report');
|
|
894
|
-
preConditionError = new Error('failed to build error report');
|
|
895
|
-
}
|
|
896
|
-
if (!preConditionError && this.config.reportData === false) {
|
|
897
|
-
this.logger.debug('skipping error report: honeybadger.js is disabled', notice);
|
|
898
|
-
preConditionError = new Error('honeybadger.js is disabled');
|
|
899
|
-
}
|
|
900
|
-
if (!preConditionError && this.__developmentMode()) {
|
|
901
|
-
this.logger.log('honeybadger.js is in development mode; the following error report will be sent in production.', notice);
|
|
902
|
-
preConditionError = new Error('honeybadger.js is in development mode');
|
|
903
|
-
}
|
|
904
|
-
if (!preConditionError && !this.config.apiKey) {
|
|
905
|
-
this.logger.warn('could not send error report: no API key has been configured', notice);
|
|
906
|
-
preConditionError = new Error('missing API key');
|
|
907
|
-
}
|
|
908
943
|
// we need to have the source file data before the beforeNotifyHandlers,
|
|
909
944
|
// in case they modify them
|
|
910
945
|
var sourceCodeData = notice && notice.backtrace ? notice.backtrace.map(function (trace) { return (0, util_1$4.shallowClone)(trace); }) : null;
|
|
911
|
-
var
|
|
912
|
-
if (
|
|
913
|
-
|
|
914
|
-
preConditionError = new Error('beforeNotify handlers returned false');
|
|
915
|
-
}
|
|
916
|
-
if (preConditionError) {
|
|
917
|
-
(0, util_1$4.runAfterNotifyHandlers)(notice, this.__afterNotifyHandlers, preConditionError);
|
|
946
|
+
var preConditionsResult = this.__runPreconditions(notice);
|
|
947
|
+
if (preConditionsResult instanceof Error) {
|
|
948
|
+
(0, util_1$4.runAfterNotifyHandlers)(notice, this.__afterNotifyHandlers, preConditionsResult);
|
|
918
949
|
return false;
|
|
919
950
|
}
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
stack: notice.stack
|
|
926
|
-
}
|
|
927
|
-
});
|
|
928
|
-
var breadcrumbs = this.__store.getContents('breadcrumbs');
|
|
929
|
-
notice.__breadcrumbs = this.config.breadcrumbsEnabled ? breadcrumbs : [];
|
|
930
|
-
(0, util_1$4.getSourceForBacktrace)(sourceCodeData, this.__getSourceFileHandler)
|
|
931
|
-
.then(function (sourcePerTrace) {
|
|
932
|
-
sourcePerTrace.forEach(function (source, index) {
|
|
933
|
-
notice.backtrace[index].source = source;
|
|
934
|
-
});
|
|
935
|
-
var payload = _this.__buildPayload(notice);
|
|
936
|
-
_this.__transport
|
|
937
|
-
.send({
|
|
938
|
-
headers: {
|
|
939
|
-
'X-API-Key': _this.config.apiKey,
|
|
940
|
-
'Content-Type': 'application/json',
|
|
941
|
-
'Accept': 'text/json, application/json'
|
|
942
|
-
},
|
|
943
|
-
method: 'POST',
|
|
944
|
-
endpoint: (0, util_1$4.endpoint)(_this.config.endpoint, '/v1/notices/js'),
|
|
945
|
-
maxObjectDepth: _this.config.maxObjectDepth,
|
|
946
|
-
logger: _this.logger,
|
|
947
|
-
}, payload)
|
|
948
|
-
.then(function (res) {
|
|
949
|
-
if (res.statusCode !== 201) {
|
|
950
|
-
(0, util_1$4.runAfterNotifyHandlers)(notice, _this.__afterNotifyHandlers, new Error("Bad HTTP response: ".concat(res.statusCode)));
|
|
951
|
-
_this.logger.warn("Error report failed: unknown response from server. code=".concat(res.statusCode));
|
|
952
|
-
return;
|
|
951
|
+
if (preConditionsResult instanceof Promise) {
|
|
952
|
+
preConditionsResult.then(function (result) {
|
|
953
|
+
if (result instanceof Error) {
|
|
954
|
+
(0, util_1$4.runAfterNotifyHandlers)(notice, _this.__afterNotifyHandlers, result);
|
|
955
|
+
return false;
|
|
953
956
|
}
|
|
954
|
-
|
|
955
|
-
(0, util_1$4.runAfterNotifyHandlers)((0, util_1$4.merge)(notice, {
|
|
956
|
-
id: uuid
|
|
957
|
-
}), _this.__afterNotifyHandlers);
|
|
958
|
-
_this.logger.info("Error report sent \u26A1 https://app.honeybadger.io/notice/".concat(uuid));
|
|
959
|
-
})
|
|
960
|
-
.catch(function (err) {
|
|
961
|
-
_this.logger.error('Error report failed: an unknown error occurred.', "message=".concat(err.message));
|
|
962
|
-
(0, util_1$4.runAfterNotifyHandlers)(notice, _this.__afterNotifyHandlers, err);
|
|
957
|
+
return _this.__send(notice, sourceCodeData);
|
|
963
958
|
});
|
|
964
|
-
|
|
959
|
+
return true;
|
|
960
|
+
}
|
|
961
|
+
this.__send(notice, sourceCodeData).catch(function (_err) { });
|
|
965
962
|
return true;
|
|
966
963
|
};
|
|
967
964
|
/**
|
|
@@ -1126,6 +1123,101 @@ var Client = /** @class */ (function () {
|
|
|
1126
1123
|
}
|
|
1127
1124
|
return tags.toString().split(TAG_SEPARATOR).filter(function (tag) { return NOT_BLANK.test(tag); });
|
|
1128
1125
|
};
|
|
1126
|
+
Client.prototype.__runPreconditions = function (notice) {
|
|
1127
|
+
var _this = this;
|
|
1128
|
+
var preConditionError = null;
|
|
1129
|
+
if (!notice) {
|
|
1130
|
+
this.logger.debug('failed to build error report');
|
|
1131
|
+
preConditionError = new Error('failed to build error report');
|
|
1132
|
+
}
|
|
1133
|
+
if (this.config.reportData === false) {
|
|
1134
|
+
this.logger.debug('skipping error report: honeybadger.js is disabled', notice);
|
|
1135
|
+
preConditionError = new Error('honeybadger.js is disabled');
|
|
1136
|
+
}
|
|
1137
|
+
if (this.__developmentMode()) {
|
|
1138
|
+
this.logger.log('honeybadger.js is in development mode; the following error report will be sent in production.', notice);
|
|
1139
|
+
preConditionError = new Error('honeybadger.js is in development mode');
|
|
1140
|
+
}
|
|
1141
|
+
if (!this.config.apiKey) {
|
|
1142
|
+
this.logger.warn('could not send error report: no API key has been configured', notice);
|
|
1143
|
+
preConditionError = new Error('missing API key');
|
|
1144
|
+
}
|
|
1145
|
+
var beforeNotifyResult = (0, util_1$4.runBeforeNotifyHandlers)(notice, this.__beforeNotifyHandlers);
|
|
1146
|
+
if (!preConditionError && !beforeNotifyResult.result) {
|
|
1147
|
+
this.logger.debug('skipping error report: one or more beforeNotify handlers returned false', notice);
|
|
1148
|
+
preConditionError = new Error('beforeNotify handlers returned false');
|
|
1149
|
+
}
|
|
1150
|
+
if (beforeNotifyResult.results.length && beforeNotifyResult.results.some(function (result) { return result instanceof Promise; })) {
|
|
1151
|
+
return Promise.allSettled(beforeNotifyResult.results)
|
|
1152
|
+
.then(function (results) {
|
|
1153
|
+
if (!preConditionError && (results.some(function (result) { return result.status === 'rejected' || result.value === false; }))) {
|
|
1154
|
+
_this.logger.debug('skipping error report: one or more beforeNotify handlers returned false', notice);
|
|
1155
|
+
preConditionError = new Error('beforeNotify handlers (async) returned false');
|
|
1156
|
+
}
|
|
1157
|
+
if (preConditionError) {
|
|
1158
|
+
return preConditionError;
|
|
1159
|
+
}
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
return preConditionError;
|
|
1163
|
+
};
|
|
1164
|
+
Client.prototype.__send = function (notice, originalBacktrace) {
|
|
1165
|
+
var _this = this;
|
|
1166
|
+
if (this.config.breadcrumbsEnabled) {
|
|
1167
|
+
this.addBreadcrumb('Honeybadger Notice', {
|
|
1168
|
+
category: 'notice',
|
|
1169
|
+
metadata: {
|
|
1170
|
+
message: notice.message,
|
|
1171
|
+
name: notice.name,
|
|
1172
|
+
stack: notice.stack
|
|
1173
|
+
}
|
|
1174
|
+
});
|
|
1175
|
+
notice.__breadcrumbs = this.__store.getContents('breadcrumbs');
|
|
1176
|
+
}
|
|
1177
|
+
else {
|
|
1178
|
+
notice.__breadcrumbs = [];
|
|
1179
|
+
}
|
|
1180
|
+
return (0, util_1$4.getSourceForBacktrace)(originalBacktrace, this.__getSourceFileHandler)
|
|
1181
|
+
.then(function (sourcePerTrace) { return __awaiter$1(_this, void 0, void 0, function () {
|
|
1182
|
+
var payload;
|
|
1183
|
+
return __generator$1(this, function (_a) {
|
|
1184
|
+
sourcePerTrace.forEach(function (source, index) {
|
|
1185
|
+
notice.backtrace[index].source = source;
|
|
1186
|
+
});
|
|
1187
|
+
payload = this.__buildPayload(notice);
|
|
1188
|
+
return [2 /*return*/, this.__transport
|
|
1189
|
+
.send({
|
|
1190
|
+
headers: {
|
|
1191
|
+
'X-API-Key': this.config.apiKey,
|
|
1192
|
+
'Content-Type': 'application/json',
|
|
1193
|
+
'Accept': 'text/json, application/json'
|
|
1194
|
+
},
|
|
1195
|
+
method: 'POST',
|
|
1196
|
+
endpoint: (0, util_1$4.endpoint)(this.config.endpoint, '/v1/notices/js'),
|
|
1197
|
+
maxObjectDepth: this.config.maxObjectDepth,
|
|
1198
|
+
logger: this.logger,
|
|
1199
|
+
}, payload)];
|
|
1200
|
+
});
|
|
1201
|
+
}); })
|
|
1202
|
+
.then(function (res) {
|
|
1203
|
+
if (res.statusCode !== 201) {
|
|
1204
|
+
(0, util_1$4.runAfterNotifyHandlers)(notice, _this.__afterNotifyHandlers, new Error("Bad HTTP response: ".concat(res.statusCode)));
|
|
1205
|
+
_this.logger.warn("Error report failed: unknown response from server. code=".concat(res.statusCode));
|
|
1206
|
+
return false;
|
|
1207
|
+
}
|
|
1208
|
+
var uuid = JSON.parse(res.body).id;
|
|
1209
|
+
(0, util_1$4.runAfterNotifyHandlers)((0, util_1$4.merge)(notice, {
|
|
1210
|
+
id: uuid
|
|
1211
|
+
}), _this.__afterNotifyHandlers);
|
|
1212
|
+
_this.logger.info("Error report sent \u26A1 https://app.honeybadger.io/notice/".concat(uuid));
|
|
1213
|
+
return true;
|
|
1214
|
+
})
|
|
1215
|
+
.catch(function (err) {
|
|
1216
|
+
_this.logger.error('Error report failed: an unknown error occurred.', "message=".concat(err.message));
|
|
1217
|
+
(0, util_1$4.runAfterNotifyHandlers)(notice, _this.__afterNotifyHandlers, err);
|
|
1218
|
+
return false;
|
|
1219
|
+
});
|
|
1220
|
+
};
|
|
1129
1221
|
return Client;
|
|
1130
1222
|
}());
|
|
1131
1223
|
client.Client = Client;
|
|
@@ -1209,13 +1301,13 @@ var __generator = (commonjsGlobal && commonjsGlobal.__generator) || function (th
|
|
|
1209
1301
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
1210
1302
|
}
|
|
1211
1303
|
};
|
|
1212
|
-
var __importDefault$
|
|
1304
|
+
var __importDefault$3 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
1213
1305
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1214
1306
|
};
|
|
1215
1307
|
Object.defineProperty(util, "__esModule", { value: true });
|
|
1216
1308
|
util.getSourceFile = util.getStats = util.fatallyLogAndExit = void 0;
|
|
1217
|
-
var os_1 = __importDefault$
|
|
1218
|
-
var fs_1 = __importDefault$
|
|
1309
|
+
var os_1 = __importDefault$3(require$$0__default["default"]);
|
|
1310
|
+
var fs_1 = __importDefault$3(require$$1__default["default"]);
|
|
1219
1311
|
var util_1$3 = require$$2__default["default"];
|
|
1220
1312
|
var readFile = (0, util_1$3.promisify)(fs_1.default.readFile);
|
|
1221
1313
|
function fatallyLogAndExit(err) {
|
|
@@ -1303,7 +1395,9 @@ function getSourceFile(path) {
|
|
|
1303
1395
|
}
|
|
1304
1396
|
util.getSourceFile = getSourceFile;
|
|
1305
1397
|
|
|
1306
|
-
var
|
|
1398
|
+
var uncaught_exception_plugin = {};
|
|
1399
|
+
|
|
1400
|
+
var uncaught_exception_monitor = {};
|
|
1307
1401
|
|
|
1308
1402
|
var aws_lambda = {};
|
|
1309
1403
|
|
|
@@ -1407,68 +1501,92 @@ function removeAwsDefaultUncaughtExceptionListener() {
|
|
|
1407
1501
|
}
|
|
1408
1502
|
aws_lambda.removeAwsDefaultUncaughtExceptionListener = removeAwsDefaultUncaughtExceptionListener;
|
|
1409
1503
|
|
|
1410
|
-
Object.defineProperty(
|
|
1411
|
-
var util_1$2 = util;
|
|
1504
|
+
Object.defineProperty(uncaught_exception_monitor, "__esModule", { value: true });
|
|
1412
1505
|
var aws_lambda_1 = aws_lambda;
|
|
1413
|
-
var
|
|
1414
|
-
var
|
|
1415
|
-
function
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1506
|
+
var util_1$2 = util;
|
|
1507
|
+
var UncaughtExceptionMonitor = /** @class */ (function () {
|
|
1508
|
+
function UncaughtExceptionMonitor(client) {
|
|
1509
|
+
this.__isReporting = false;
|
|
1510
|
+
this.__handlerAlreadyCalled = false;
|
|
1511
|
+
this.__client = client;
|
|
1512
|
+
this.removeAwsLambdaListener();
|
|
1419
1513
|
}
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1514
|
+
UncaughtExceptionMonitor.prototype.removeAwsLambdaListener = function () {
|
|
1515
|
+
var isLambda = !!process.env.LAMBDA_TASK_ROOT;
|
|
1516
|
+
if (!isLambda) {
|
|
1517
|
+
return;
|
|
1518
|
+
}
|
|
1519
|
+
(0, aws_lambda_1.removeAwsDefaultUncaughtExceptionListener)();
|
|
1520
|
+
};
|
|
1521
|
+
/**
|
|
1522
|
+
* If there are no other uncaughtException listeners,
|
|
1523
|
+
* we want to report the exception to Honeybadger and
|
|
1524
|
+
* mimic the default behavior of NodeJs,
|
|
1525
|
+
* which is to exit the process with code 1
|
|
1526
|
+
*/
|
|
1527
|
+
UncaughtExceptionMonitor.prototype.hasOtherUncaughtExceptionListeners = function () {
|
|
1528
|
+
var allListeners = process.listeners('uncaughtException');
|
|
1529
|
+
// Node sets up these listeners when we use domains
|
|
1530
|
+
// Since they're not set up by a user, they shouldn't affect whether we exit or not
|
|
1531
|
+
var domainListeners = allListeners.filter(function (listener) {
|
|
1532
|
+
listener.name === 'domainUncaughtExceptionClear';
|
|
1533
|
+
});
|
|
1534
|
+
return allListeners.length - domainListeners.length > 1;
|
|
1535
|
+
};
|
|
1536
|
+
UncaughtExceptionMonitor.prototype.handleUncaughtException = function (uncaughtError) {
|
|
1537
|
+
var _this = this;
|
|
1538
|
+
if (this.__isReporting) {
|
|
1539
|
+
return;
|
|
1540
|
+
}
|
|
1541
|
+
if (!this.__client.config.enableUncaught) {
|
|
1542
|
+
this.__client.config.afterUncaught(uncaughtError);
|
|
1543
|
+
if (!this.hasOtherUncaughtExceptionListeners()) {
|
|
1544
|
+
(0, util_1$2.fatallyLogAndExit)(uncaughtError);
|
|
1545
|
+
}
|
|
1546
|
+
return;
|
|
1547
|
+
}
|
|
1548
|
+
// report only the first error - prevent reporting recursive errors
|
|
1549
|
+
if (this.__handlerAlreadyCalled) {
|
|
1550
|
+
if (!this.hasOtherUncaughtExceptionListeners()) {
|
|
1551
|
+
(0, util_1$2.fatallyLogAndExit)(uncaughtError);
|
|
1552
|
+
}
|
|
1553
|
+
return;
|
|
1554
|
+
}
|
|
1555
|
+
this.__isReporting = true;
|
|
1556
|
+
this.__client.notify(uncaughtError, {
|
|
1557
|
+
afterNotify: function (_err, _notice) {
|
|
1558
|
+
_this.__isReporting = false;
|
|
1559
|
+
_this.__handlerAlreadyCalled = true;
|
|
1560
|
+
_this.__client.config.afterUncaught(uncaughtError);
|
|
1561
|
+
if (!_this.hasOtherUncaughtExceptionListeners()) {
|
|
1562
|
+
(0, util_1$2.fatallyLogAndExit)(uncaughtError);
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
});
|
|
1566
|
+
};
|
|
1567
|
+
return UncaughtExceptionMonitor;
|
|
1568
|
+
}());
|
|
1569
|
+
uncaught_exception_monitor.default = UncaughtExceptionMonitor;
|
|
1570
|
+
|
|
1571
|
+
var __importDefault$2 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
1572
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1573
|
+
};
|
|
1574
|
+
Object.defineProperty(uncaught_exception_plugin, "__esModule", { value: true });
|
|
1575
|
+
var uncaught_exception_monitor_1 = __importDefault$2(uncaught_exception_monitor);
|
|
1431
1576
|
function default_1$1() {
|
|
1432
1577
|
return {
|
|
1433
1578
|
load: function (client) {
|
|
1434
1579
|
if (!client.config.enableUncaught) {
|
|
1435
1580
|
return;
|
|
1436
1581
|
}
|
|
1437
|
-
|
|
1582
|
+
var uncaughtExceptionMonitor = new uncaught_exception_monitor_1.default(client);
|
|
1438
1583
|
process.on('uncaughtException', function honeybadgerUncaughtExceptionListener(uncaughtError) {
|
|
1439
|
-
|
|
1440
|
-
client.config.afterUncaught(uncaughtError);
|
|
1441
|
-
if (!hasOtherUncaughtExceptionListeners()) {
|
|
1442
|
-
(0, util_1$2.fatallyLogAndExit)(uncaughtError);
|
|
1443
|
-
}
|
|
1444
|
-
return;
|
|
1445
|
-
}
|
|
1446
|
-
// report only the first error - prevent reporting recursive errors
|
|
1447
|
-
if (handlerAlreadyCalled) {
|
|
1448
|
-
if (!hasOtherUncaughtExceptionListeners()) {
|
|
1449
|
-
(0, util_1$2.fatallyLogAndExit)(uncaughtError);
|
|
1450
|
-
}
|
|
1451
|
-
return;
|
|
1452
|
-
}
|
|
1453
|
-
if (isReporting$1) {
|
|
1454
|
-
return;
|
|
1455
|
-
}
|
|
1456
|
-
isReporting$1 = true;
|
|
1457
|
-
client.notify(uncaughtError, {
|
|
1458
|
-
afterNotify: function (_err, _notice) {
|
|
1459
|
-
isReporting$1 = false;
|
|
1460
|
-
handlerAlreadyCalled = true;
|
|
1461
|
-
client.config.afterUncaught(uncaughtError);
|
|
1462
|
-
if (!hasOtherUncaughtExceptionListeners()) {
|
|
1463
|
-
(0, util_1$2.fatallyLogAndExit)(uncaughtError);
|
|
1464
|
-
}
|
|
1465
|
-
}
|
|
1466
|
-
});
|
|
1584
|
+
uncaughtExceptionMonitor.handleUncaughtException(uncaughtError);
|
|
1467
1585
|
});
|
|
1468
1586
|
}
|
|
1469
1587
|
};
|
|
1470
1588
|
}
|
|
1471
|
-
|
|
1589
|
+
uncaught_exception_plugin.default = default_1$1;
|
|
1472
1590
|
|
|
1473
1591
|
var unhandled_rejection = {};
|
|
1474
1592
|
|
|
@@ -1787,7 +1905,7 @@ stacked_store.StackedStore = StackedStore;
|
|
|
1787
1905
|
var domain_1 = __importDefault(require$$1__default$1["default"]);
|
|
1788
1906
|
var core_1 = src;
|
|
1789
1907
|
var util_1 = util;
|
|
1790
|
-
var
|
|
1908
|
+
var uncaught_exception_plugin_1 = __importDefault(uncaught_exception_plugin);
|
|
1791
1909
|
var unhandled_rejection_1 = __importDefault(unhandled_rejection);
|
|
1792
1910
|
var middleware_1 = middleware;
|
|
1793
1911
|
var aws_lambda_1 = aws_lambda;
|
|
@@ -1800,7 +1918,7 @@ stacked_store.StackedStore = StackedStore;
|
|
|
1800
1918
|
if (opts === void 0) { opts = {}; }
|
|
1801
1919
|
var _this = this;
|
|
1802
1920
|
var _a;
|
|
1803
|
-
_this = _super.call(this, __assign({
|
|
1921
|
+
_this = _super.call(this, __assign({ projectRoot: process.cwd(), hostname: os_1.default.hostname() }, opts), new transport_1.ServerTransport()) || this;
|
|
1804
1922
|
/** @internal */
|
|
1805
1923
|
_this.__beforeNotifyHandlers = [
|
|
1806
1924
|
function (notice) {
|
|
@@ -1889,14 +2007,14 @@ stacked_store.StackedStore = StackedStore;
|
|
|
1889
2007
|
}(core_1.Client));
|
|
1890
2008
|
var singleton = new Honeybadger({
|
|
1891
2009
|
__plugins: [
|
|
1892
|
-
(0,
|
|
2010
|
+
(0, uncaught_exception_plugin_1.default)(),
|
|
1893
2011
|
(0, unhandled_rejection_1.default)()
|
|
1894
2012
|
],
|
|
1895
2013
|
});
|
|
1896
2014
|
var NOTIFIER = {
|
|
1897
2015
|
name: '@honeybadger-io/js',
|
|
1898
2016
|
url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/js',
|
|
1899
|
-
version: '6.
|
|
2017
|
+
version: '6.4.1'
|
|
1900
2018
|
};
|
|
1901
2019
|
singleton.setNotifier(NOTIFIER);
|
|
1902
2020
|
var core_2 = src;
|