Skip to content

Commit c5bb1a0

Browse files
fix(exception_handling): catch uncaught exeption in HTTP response handling
1 parent e06deab commit c5bb1a0

File tree

6 files changed

+29
-7
lines changed

6 files changed

+29
-7
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.62.1] - 2023-10-23
9+
10+
### Fixed
11+
12+
- Catch uncaught exception in HTTP response handling
13+
814
## [1.62.0] - 2023-10-10
915

1016
### Fixed

dist/vwo-javascript-sdk.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vwo-javascript-sdk.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vwo-javascript-sdk.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vwo-javascript-sdk.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/utils/HttpHandlerUtil.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ const https = require('https');
1818

1919
const DataTypeUtil = require('./DataTypeUtil');
2020
const Constants = require('../constants');
21+
const logging = require('../services/logging');
22+
const FileNameEnum = require('../enums/FileNameEnum');
23+
const { LogLevelEnum, LogMessageEnum, LogMessageUtil } = logging;
24+
const logger = logging.getLogger();
2125

2226
const HttpHandlerUtil = {
2327
sendGetCall: function(url, queryParams, authToken, callback, customHeaders = {}) {
@@ -45,7 +49,19 @@ const HttpHandlerUtil = {
4549
});
4650
res.on('end', function() {
4751
if (callback && DataTypeUtil.isFunction(callback)) {
48-
callback(null, { endPoint, rawData: JSON.parse(rawData) });
52+
try {
53+
callback(null, { endPoint, rawData: JSON.parse(rawData) });
54+
} catch (err) {
55+
const serverResponse = err + ', Server Response -- ' + rawData;
56+
logger.log(
57+
LogLevelEnum.ERROR,
58+
LogMessageUtil.build(LogMessageEnum.ERROR_MESSAGES.IMPRESSION_FAILED, {
59+
file: FileNameEnum.EventDispatcher,
60+
endPoint,
61+
err: serverResponse
62+
})
63+
);
64+
}
4965
}
5066
});
5167
res.on('error', function(err) {

0 commit comments

Comments
 (0)