Permalink
Browse files

try to let txnQueue empty before reload

  • Loading branch information...
1 parent dab3c6d commit cf1762a3792d42161768cafd017e29c5ff3f7a45 @nateps nateps committed Oct 9, 2012
Showing with 13 additions and 1 deletion.
  1. +13 −1 lib/derby.browser.js
View
@@ -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);

0 comments on commit cf1762a

Please sign in to comment.