Skip to content

Commit c293e4c

Browse files
committed
fix: bugsnag errors in git workflows due to race conditions
The catch block was attached after a delay in some cases and errors before attaching the catch block in progress dialog used to get treated as uncaught exceptions and get logged in bugsnag fixed by modifying the timing chain and have a catch handler attached to promise at first itself.
1 parent 733a772 commit c293e4c

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

src/extensions/default/Git/src/dialogs/Progress.js

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,17 @@ define(function (require, exports) {
8585
onProgress();
8686
}
8787

88+
let finalValue, finalError;
8889
function finish() {
8990
finished = true;
9091
if (dialog) {
9192
dialog.close();
9293
}
93-
promise.then(function (val) {
94-
resolve(val);
95-
}).catch(function (err) {
96-
reject(err);
97-
});
94+
if(finalError){
95+
reject(finalError);
96+
} else {
97+
resolve(finalValue);
98+
}
9899
}
99100

100101
if (!options.preDelay) {
@@ -109,17 +110,24 @@ define(function (require, exports) {
109110
progressTracker.on(`${Events.GIT_PROGRESS_EVENT}.progressDlg`, (_evt, data)=>{
110111
onProgress(data);
111112
});
112-
promise.finally(function () {
113-
progressTracker.off(`${Events.GIT_PROGRESS_EVENT}.progressDlg`);
114-
onProgress("Finished!");
115-
if (!options.postDelay || !dialog) {
116-
finish();
117-
} else {
118-
setTimeout(function () {
113+
promise
114+
.then(val => {
115+
finalValue = val;
116+
})
117+
.catch(err => {
118+
finalError = err;
119+
})
120+
.finally(function () {
121+
progressTracker.off(`${Events.GIT_PROGRESS_EVENT}.progressDlg`);
122+
onProgress("Finished!");
123+
if (!options.postDelay || !dialog) {
119124
finish();
120-
}, options.postDelay * 1000);
121-
}
122-
});
125+
} else {
126+
setTimeout(function () {
127+
finish();
128+
}, options.postDelay * 1000);
129+
}
130+
});
123131

124132
});
125133
}

src/loggerSetup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
*/
2020

21-
/*globals Bugsnag, AppConfig, Phoenix*/
21+
/*globals Bugsnag, AppConfig*/
2222
// window.AppConfig comes from appConfig.js built by gulp scripts at build time
2323

2424
(function(){
@@ -32,7 +32,7 @@
3232
"https://dev.phcode.dev", // dev url
3333
"https://staging.phcode.dev" // staging url
3434
];
35-
let isBugsnagLoggableURL = false;
35+
let isBugsnagLoggableURL = false; // to test bugsnag in dev builds, set this to true
3636
for(let loggableURL of loggableURLS){
3737
if(window.location.href.startsWith(loggableURL)){
3838
isBugsnagLoggableURL = true;

0 commit comments

Comments
 (0)