Skip to content

Commit

Permalink
try to let txnQueue empty before reload
Browse files Browse the repository at this point in the history
  • Loading branch information
nateps committed Oct 9, 2012
1 parent dab3c6d commit cf1762a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/derby.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,19 @@ function init(modelBundle, appHash, debug, ns, ctx) {
racer.on('ready', function(model) {
model.socket.on('connect', function() {
model.socket.emit('derbyClient', appHash, function(reload) {
if (reload) window.location.reload(true);
if (reload) {
var retries = 0
, reloadOnEmpty = function() {
// TODO: Don't hack the Racer internal API so much
if (model._txnQueue.length && retries++ < 20) {
// Clear out private path transactions that could get stuck
model._specModel();
return setTimeout(reloadOnEmpty, 100);
}
window.location.reload(true);
}
reloadOnEmpty();
}
});
});
if (debug) autoRefresh(view, model);
Expand Down

0 comments on commit cf1762a

Please sign in to comment.