Skip to content

Commit

Permalink
[patch] Added patch for SockJS to add a missing onerror listener for …
Browse files Browse the repository at this point in the history
…WebSockets
  • Loading branch information
3rd-Eden committed Mar 27, 2014
1 parent 36da5bb commit bf3f45f
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions transformers/sockjs/patches/wsonerror.patch
@@ -0,0 +1,32 @@
diff --git a/transformers/sockjs/library.js b/transformers/sockjs/library.js
index 26cccb0..30f8792 100644
--- a/transformers/sockjs/library.js
+++ b/transformers/sockjs/library.js
@@ -939,7 +939,7 @@ var SockJS = function(url, dep_protocols_whitelist, options) {
// makes `new` optional
return new SockJS(url, dep_protocols_whitelist, options);
}
-
+
var that = this, protocols_whitelist;
that._options = {devel: false, debug: false, protocols_whitelist: [],
info: undefined, rtt: undefined};
@@ -1215,6 +1215,9 @@ var WebSocketTransport = SockJS.websocket = function(ri, trans_url) {
that.ws.onmessage = function(e) {
that.ri._didMessage(e.data);
};
+ that.ws.onerror = function() {
+ ri._didMessage(utils.closeFrame(1006, "WebSocket connection broken"));
+ };
// Firefox has an interesting bug. If a websocket connection is
// created after onunload, it stays alive even when user
// navigates away from the page. In such situation let's lie -
@@ -1235,7 +1238,7 @@ WebSocketTransport.prototype.doCleanup = function() {
var that = this;
var ws = that.ws;
if (ws) {
- ws.onmessage = ws.onclose = null;
+ ws.onmessage = ws.onclose = ws.onerror = null;
ws.close();
utils.unload_del(that.unload_ref);
that.unload_ref = that.ri = that.ws = null;

0 comments on commit bf3f45f

Please sign in to comment.