[Pkg-javascript-commits] [sockjs-client] 171/350: Fix xdr cleanup. Add debug to xdr.
tonnerre at ancient-solutions.com
tonnerre at ancient-solutions.com
Fri Aug 5 01:04:12 UTC 2016
This is an automated email from the git hooks/post-receive script.
tonnerre-guest pushed a commit to branch upstream
in repository sockjs-client.
commit 26f80b6412bdadf3a5e3c13e59cab506c8b8645e
Author: Bryce Kahle <bkahle at gmail.com>
Date: Fri Oct 17 16:21:02 2014 -0400
Fix xdr cleanup. Add debug to xdr.
---
lib/transport/sender/xdr.js | 29 ++++++++++++++++++++++-------
tests/lib/echo-tests.js | 1 +
2 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/lib/transport/sender/xdr.js b/lib/transport/sender/xdr.js
index b49b13e..4761d1c 100644
--- a/lib/transport/sender/xdr.js
+++ b/lib/transport/sender/xdr.js
@@ -3,6 +3,7 @@
var EventEmitter = require('events').EventEmitter
, util = require('util')
, eventUtils = require('../../utils/event')
+ , debug = require('debug')('sockjs-client:sender:xdr')
;
// References:
@@ -10,6 +11,7 @@ var EventEmitter = require('events').EventEmitter
// http://msdn.microsoft.com/en-us/library/cc288060(v=VS.85).aspx
function XDRObject(method, url, payload) {
+ debug(method, url);
var self = this;
EventEmitter.call(this);
@@ -21,19 +23,26 @@ function XDRObject(method, url, payload) {
util.inherits(XDRObject, EventEmitter);
XDRObject.prototype._start = function(method, url, payload) {
+ debug('_start');
var self = this;
var xdr = new global.XDomainRequest();
// IE caches even POSTs
url += ((url.indexOf('?') === -1) ? '?' : '&') + 't=' + Date.now();
- var onerror = xdr.ontimeout = xdr.onerror = function() {
- self.emit('finish', 0, '');
- self._cleanup(false);
+ xdr.onerror = function() {
+ debug('onerror');
+ self._error();
+ };
+ xdr.ontimeout = function () {
+ debug('ontimeout');
+ self._error();
};
xdr.onprogress = function() {
+ debug('progress', xdr.responseText);
self.emit('chunk', 200, xdr.responseText);
};
xdr.onload = function() {
+ debug('load');
self.emit('finish', 200, xdr.responseText);
self._cleanup(false);
};
@@ -46,18 +55,24 @@ XDRObject.prototype._start = function(method, url, payload) {
this.xdr.open(method, url);
this.xdr.send(payload);
} catch(x) {
- onerror();
+ this._error();
}
};
+XDRObject.prototype._error = function() {
+ this.emit('finish', 0, '');
+ this._cleanup(false);
+};
+
XDRObject.prototype._cleanup = function(abort) {
+ debug('cleanup', abort);
if (!this.xdr) {
return;
}
+ this.removeAllListeners();
eventUtils.unloadDel(this.unloadRef);
- this.xdr.ontimeout = this.xdr.onerror = this.xdr.onprogress =
- this.xdr.onload = null;
+ this.xdr.ontimeout = this.xdr.onerror = this.xdr.onprogress = this.xdr.onload = null;
if (abort) {
try {
this.xdr.abort();
@@ -67,7 +82,7 @@ XDRObject.prototype._cleanup = function(abort) {
};
XDRObject.prototype.close = function() {
- this.removeAllListeners();
+ debug('close');
this._cleanup(true);
};
diff --git a/tests/lib/echo-tests.js b/tests/lib/echo-tests.js
index e4dd72d..cf40b50 100644
--- a/tests/lib/echo-tests.js
+++ b/tests/lib/echo-tests.js
@@ -93,6 +93,7 @@ module.exports.echoFromChild = function echoFromChild(transport) {
done();
return;
}
+ this.timeout(10000);
var title = this.runnable().fullTitle();
debug('start', title);
--
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