[Pkg-javascript-commits] [sockjs-client] 128/434: EventSource crashes chrome < 15 and safari when window is closed too quickly.

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:08 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch master
in repository sockjs-client.

commit 68f16449f9fd04baa8c38c0fe05a320d7fc77310
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Tue Sep 6 13:23:48 2011 +0100

    EventSource crashes chrome < 15 and safari when window is closed too quickly.
---
 lib/trans-receiver-eventsource.js | 7 ++++++-
 lib/utils.js                      | 8 ++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/lib/trans-receiver-eventsource.js b/lib/trans-receiver-eventsource.js
index add475e..ad60da7 100644
--- a/lib/trans-receiver-eventsource.js
+++ b/lib/trans-receiver-eventsource.js
@@ -15,7 +15,12 @@ var EventSourceReceiver = function(url) {
         // EventSource reconnects automatically.
         es.close();
         es = null;
-        that.dispatchEvent(new SimpleEvent('close', {reason: reason}));
+        // Safari and chrome < 15 crash if we close window before
+        // waiting for ES cleanup. See:
+        //   https://code.google.com/p/chromium/issues/detail?id=89155
+        utils.delay(200, function() {
+                        that.dispatchEvent(new SimpleEvent('close', {reason: reason}));
+                    });
     };
 };
 
diff --git a/lib/utils.js b/lib/utils.js
index 2b4b706..d9bc5be 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -337,3 +337,11 @@ utils.arrIndexOf = function(arr, obj){
 	}
     return -1;
 };
+
+utils.delay = function(t, fun) {
+    if(typeof t === 'function') {
+        fun = t;
+        t = 0;
+    }
+    setTimeout(fun, t);
+};
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list