Skip to content

Commit

Permalink
Fix stall that can occur if a connect fails whilst posting
Browse files Browse the repository at this point in the history
Requires post checking to be active, 'connect-fail' error skipping and some working connections
Ref #99
  • Loading branch information
animetosho committed Jan 12, 2024
1 parent 58fc88b commit 9a4b4ce
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,28 +242,28 @@ Uploader.prototype = {
self.postActive++;
c.post(post, function(err, messageId) {
self.postActive--;
var postCompletionCb = doPost;
if(err) {
if(self.cancelled && err.code == 'cancelled') return;
dumpPost(self, post); // post.data guaranteed to be set here

// handle error skipping
err.skippable = true;
var isPostFailure = (['connect_fail','connection_ended','not_connected'].indexOf(err.code) == -1);
if(messageId) {
if(err.code == 'timeout' && self.skipErrs['post-timeout']) {
self._markPostError(post, 'Posting timed out');
} else if((err.code == 'post_denied' || err.code == 'bad_response' || err.code == 'unknown_error') && self.skipErrs['post-reject']) {
self._markPostError(post, 'Post rejected (' + err.message + ')');
} else if(err.code == 'connection_ended' || err.code == 'not_connected') { // internal error - cannot continue
return doPost(err);
} else if(self.skipErrs['post-fail'] && err.code != 'connect_fail') {
} else if(self.skipErrs['post-fail'] && isPostFailure) {
self._markPostError(post, 'Posting failed (' + err.message + ')');
} else
return doPost(err);
} else if(self.skipErrs['post-fail'] && ['connect_fail','connection_ended','not_connected'].indexOf(err.code) == -1) {
postCompletionCb = doPost.bind(null, err);
} else if(self.skipErrs['post-fail'] && isPostFailure) {
post.messageId = null; // skipping post where Message-ID is completely invalid
self._markPostError(post, 'Posting failed (' + err.message + ')');
} else
return doPost(err);
postCompletionCb = doPost.bind(null, err);
}
self.articlesPosted++;
self.bytesPosted += post.inputLen;
Expand All @@ -286,7 +286,7 @@ Uploader.prototype = {
return;
} else {
post.successful = !err;
self._postComplete(post, err, doPost);
self._postComplete(post, err, postCompletionCb);
}
});
});
Expand Down

0 comments on commit 9a4b4ce

Please sign in to comment.