Gilroy Posted April 8, 2016 Report Share Posted April 8, 2016 .getReceivedItems sometimes messes up with a 503 error is there anything i can do so that i can retry or make it try again on the 'receivedOfferChanged' condition? Quote Link to comment Share on other sites More sharing options...
Mole Posted April 8, 2016 Report Share Posted April 8, 2016 Just add it to the queue again / retry. function getItems(offer, callback) { offer.getReceivedItems(function(err) { if (err) return getItems(offer, callback); }); } Quote Link to comment Share on other sites More sharing options...
cookie Posted April 9, 2016 Report Share Posted April 9, 2016 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. Quote Link to comment Share on other sites More sharing options...
Mole Posted April 9, 2016 Report Share Posted April 9, 2016 (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 April 9, 2016 by Mole Quote Link to comment Share on other sites More sharing options...
Gilroy Posted April 9, 2016 Author Report Share Posted April 9, 2016 yeah the first example gave me an idea thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.