Jump to content
McKay Development

Recommended Posts

Posted

Just add it to the queue again / retry.

 

function getItems(offer, callback) {
    offer.getReceivedItems(function(err) {
        if (err) return getItems(offer, callback);
    });
}
Posted

Just add it to the queue again / retry.

 

function getItems(offer, callback) {
    offer.getReceivedItems(function(err) {
        if (err) return getItems(offer, callback);
    });
}

 

Very bad there should be a timeout for this, because maybe the session got killed and it will keep recalling it forever.

Posted (edited)

var config = {
maxRetries: 5
};

function getItems(offer, retries, callback) {
if (typeof retries === 'function') {
callback = retries;
retries = 0;
}

if (retries >= config.maxRetries) return callback(new Error('Max retries reached!'));

offer.getReceivedItems(function(err, items) {
if (err) return getItems(offer, retries + 1, callback);
return callback(null, items);
});
}
Better? It was just a simple example, not a serious code... Edited by Mole

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...