Skip to content

Commit

Permalink
Merge pull request #748 from telefonicaid/task/check_domain_context
Browse files Browse the repository at this point in the history
check domain before access domain.context
  • Loading branch information
fgalan committed Sep 26, 2023
2 parents 26214a9 + 2a61f0f commit 41e53ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
@@ -1,3 +1,4 @@
- Fix: check domain before access domain
- Fix: expandVar return a 'null' instead of null (#746)
- Fix: smtp and smpp logs (#738)
- Add: allow access entities using NGSIv2 API for non_signal rules (new setting nonSignalByAPI / PERSEO_CHECK_NON_SIGNAL_BY_API) (#549)
Expand Down
8 changes: 4 additions & 4 deletions lib/myutils.js
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 41e53ad

Please sign in to comment.