Skip to content

Commit

Permalink
check domain before access domain.context
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroVega committed Sep 22, 2023
1 parent 26214a9 commit 6b4a7ac
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/myutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function requestHelperAux(method, options, withMetrics, callback) {
}
}
options.headers = headers;
if (withMetrics && options.json && domain.context) {
if (withMetrics && options.json && domain && domain.context) {
try {
metrics.IncMetrics(
domain.context.srv,
Expand All @@ -157,7 +157,7 @@ function requestHelperAux(method, options, withMetrics, callback) {
}
request[method](options, function cbRequest2core(err, response, body) {
var bodySz = 0;
if (withMetrics && domain.context) {
if (withMetrics && domain && domain.context) {
if (body) {
if (typeof body === 'string') {
bodySz = Buffer.byteLength(body);
Expand All @@ -178,7 +178,7 @@ function requestHelperAux(method, options, withMetrics, callback) {
}
if (err) {
logErrorIf(err, util.format('error %s to %s', method, options.url));
if (withMetrics && domain.context) {
if (withMetrics && domain && domain.context) {
metrics.IncMetrics(domain.context.srv, domain.context.subsrv, metrics.outgoingTransactionsErrors);
}
return callback(err, null);
Expand All @@ -196,7 +196,7 @@ function requestHelperAux(method, options, withMetrics, callback) {
);
localError.httpCode = respObj.code < 500 && respObj.code >= 400 ? respObj.code : 500;
logErrorIf(localError, null, domain && domain.context);
if (withMetrics && domain.context) {
if (withMetrics && domain && domain.context) {
metrics.IncMetrics(domain.context.srv, domain.context.subsrv, metrics.outgoingTransactionsErrors);
}
return callback(localError, respObj);
Expand Down

0 comments on commit 6b4a7ac

Please sign in to comment.