Skip to content

Commit 76cbf98

Browse files
Send usage report on update upload progress bar failure
1 parent a2cea14 commit 76cbf98

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

bin/helpers/constants.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ const userMessages = {
110110
"Value for the 'spec_timeout' key not in the 1-120 range. Going ahead with 30 mins as the default spec timeout. Read more about how to specify the option in https://browserstack.com/docs/automate/cypress/spec-timeout",
111111
SPEC_LIMIT_SUCCESS_MESSAGE:
112112
"Spec timeout specified as <x> minutes. If any of your specs exceed the specified time limit, it would be forcibly killed by BrowserStack",
113+
NO_CONNECTION_WHILE_UPDATING_UPLOAD_PROGRESS_BAR:
114+
"Connection is undefined/null for zip upload request. Unable to determine progress."
113115
};
114116

115117
const validationMessages = {

bin/helpers/zipUpload.js

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ const purgeUploadBar = (obj) => {
2121

2222
const uploadSuits = (bsConfig, filePath, opts, obj) => {
2323
return new Promise(function (resolve, reject) {
24+
let uploadProgressBarErrorFlags = {
25+
noConnectionReportSent: false,
26+
unknownErrorReportSent: false
27+
};
2428
obj.startTime = Date.now();
2529

2630
if (opts.urlPresent) {
@@ -96,6 +100,7 @@ const uploadSuits = (bsConfig, filePath, opts, obj) => {
96100
});
97101

98102
obj.zipInterval = setInterval(function () {
103+
const errorCode = 'update_upload_progress_bar_failed';
99104
try {
100105
if (r && r.req && r.req.connection) {
101106
let dispatched = r.req.connection._bytesDispatched;
@@ -104,11 +109,35 @@ const uploadSuits = (bsConfig, filePath, opts, obj) => {
104109
speed: ((dispatched / (Date.now() - obj.startTime)) / 125).toFixed(2) //kbits per sec
105110
});
106111
} else {
107-
logger.warn('Connection is undefined/null for zip upload request. Unable to determine progress.');
112+
if (!uploadProgressBarErrorFlags.noConnectionReportSent) {
113+
logger.warn(Constants.userMessages.NO_CONNECTION_WHILE_UPDATING_UPLOAD_PROGRESS_BAR);
114+
utils.sendUsageReport(
115+
bsConfig,
116+
null,
117+
Constants.userMessages.NO_CONNECTION_WHILE_UPDATING_UPLOAD_PROGRESS_BAR,
118+
Constants.messageTypes.WARNING,
119+
errorCode,
120+
null,
121+
null
122+
);
123+
uploadProgressBarErrorFlags.noConnectionReportSent = true;
124+
}
108125
}
109126
} catch (error) {
110-
logger.warn('Unable to determine progress.');
111-
logger.error(error);
127+
if (!uploadProgressBarErrorFlags.unknownErrorReportSent) {
128+
logger.warn('Unable to determine progress.');
129+
logger.error(error);
130+
utils.sendUsageReport(
131+
bsConfig,
132+
null,
133+
error.message,
134+
Constants.messageTypes.WARNING,
135+
errorCode,
136+
null,
137+
null
138+
);
139+
uploadProgressBarErrorFlags.unknownErrorReportSent = true;
140+
}
112141
}
113142
}, 150);
114143

0 commit comments

Comments
 (0)