window.beforeunload event kills sockjs connection #170

Closed
jackp opened this Issue Jun 2, 2012 · 3 comments

Comments

Projects
None yet
4 participants

jackp commented Jun 2, 2012

Hello,

I currently have a function that goes something like this:

var changed = true;
var intervalID = setInterval(function(){
  console.log('changed = ' + changed);
  if(changed){
    Meteor.call(updateStory, id, story, function({
      changed = false;
    });
  }
}, 10000);

window.onbeforeunload = function(e){
  e = e || window.event;
  if(changed){
    if(e){
      e.returnValue = 'warning message...';
    }
    return 'warning message...';
  }
};

The onbeforeunload event works, but if you choose to "stay on page" in the alert box, it seems to kill the sockjs connection. The interval function continues to run, but the Meteor.call() function does not.

When I insert Meteor.status(), it says that meteor is still connected. I even tried using Meteor.reconnect and it did not work.

Any ideas?

Owner

debergalis commented Sep 19, 2012

Also see #339

Contributor

avital commented Nov 25, 2012

I think this is sockjs/sockjs-client#90

Owner

glasser commented Apr 19, 2014

The linked sockjs bug was fixed and we've had that version in meteor for a while. Closing; we can reopen if somebody says this is still an issue.

@glasser glasser closed this Apr 19, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment