message_bus 2.1.3 → 2.1.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of message_bus might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG +2 -1
- data/assets/message-bus.js +20 -3
- data/lib/message_bus/version.rb +1 -1
- data/vendor/assets/javascripts/message-bus.js +20 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab4e02e88e557c6eeeedbe109bdcde769d139ea8
|
4
|
+
data.tar.gz: 39009dd918e0218b44817bcbe76af71f7dc756d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbf23d9b541c1045074433945d9cccf10c0b40f445ac5f4692a6d3308dfc21d60f70f70cf4d5a93d83e653f570c7966ce1384def2c1b569daa49c9dd89b872c1
|
7
|
+
data.tar.gz: 3bf340e084d49dfeb09a07e80b23e2dc9698f2863feb579e668c449891c9bc7dec2f67b52dc891e7f1c772ecd0ce9f9b33f00b7fb9f34d1014d9dc6942496d0f
|
data/CHANGELOG
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
20-04-2018
|
2
2
|
|
3
|
-
- Version 2.1.
|
3
|
+
- Version 2.1.4
|
4
4
|
|
5
5
|
- FIX: Subtle issue where poll timeout may not be cleared causing multiple concurrent polls
|
6
|
+
- FIX: Add extra protection for poller to ensure there is never a case where multiple ajax happens concurrently
|
6
7
|
|
7
8
|
09-01-2018
|
8
9
|
|
data/assets/message-bus.js
CHANGED
@@ -7,6 +7,8 @@
|
|
7
7
|
var callbacks, clientId, failCount, shouldLongPoll, queue, responseCallbacks, uniqueId, baseUrl;
|
8
8
|
var me, started, stopped, longPoller, pollTimeout, paused, later, jQuery, interval, chunkedBackoff;
|
9
9
|
|
10
|
+
var ajaxInProgress = false;
|
11
|
+
|
10
12
|
uniqueId = function() {
|
11
13
|
return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
12
14
|
var r, v;
|
@@ -132,7 +134,13 @@
|
|
132
134
|
return false;
|
133
135
|
};
|
134
136
|
|
135
|
-
longPoller = function(poll,data){
|
137
|
+
longPoller = function(poll, data) {
|
138
|
+
|
139
|
+
if (ajaxInProgress) {
|
140
|
+
// never allow concurrent ajax reqs
|
141
|
+
return;
|
142
|
+
}
|
143
|
+
|
136
144
|
var gotData = false;
|
137
145
|
var aborted = false;
|
138
146
|
lastAjax = new Date();
|
@@ -211,6 +219,7 @@
|
|
211
219
|
|
212
220
|
updateLastAjax();
|
213
221
|
|
222
|
+
ajaxInProgress = true;
|
214
223
|
var req = me.ajax({
|
215
224
|
url: me.baseUrl + "message-bus/" + me.clientId + "/poll" + (!longPoll ? "?dlp=t" : ""),
|
216
225
|
data: data,
|
@@ -262,6 +271,9 @@
|
|
262
271
|
}
|
263
272
|
},
|
264
273
|
complete: function() {
|
274
|
+
|
275
|
+
ajaxInProgress = false;
|
276
|
+
|
265
277
|
var interval;
|
266
278
|
try {
|
267
279
|
if (gotData || aborted) {
|
@@ -362,7 +374,8 @@
|
|
362
374
|
if (callbacks.length === 0 || hiddenTabShouldWait()) {
|
363
375
|
if(!delayPollTimeout) {
|
364
376
|
delayPollTimeout = setTimeout(function() {
|
365
|
-
delayPollTimeout = null;
|
377
|
+
delayPollTimeout = null;
|
378
|
+
poll();
|
366
379
|
}, parseInt(500 + Math.random() * 500));
|
367
380
|
}
|
368
381
|
return;
|
@@ -373,7 +386,7 @@
|
|
373
386
|
data[callbacks[i].channel] = callbacks[i].last_id;
|
374
387
|
}
|
375
388
|
|
376
|
-
me.longPoll = longPoller(poll,data);
|
389
|
+
me.longPoll = longPoller(poll, data);
|
377
390
|
};
|
378
391
|
|
379
392
|
|
@@ -381,7 +394,11 @@
|
|
381
394
|
if(document.addEventListener && 'hidden' in document){
|
382
395
|
me.visibilityEvent = global.document.addEventListener('visibilitychange', function(){
|
383
396
|
if(!document.hidden && !me.longPoll && pollTimeout){
|
397
|
+
|
384
398
|
clearTimeout(pollTimeout);
|
399
|
+
clearTimeout(delayPollTimeout);
|
400
|
+
|
401
|
+
delayPollTimeout = null;
|
385
402
|
pollTimeout = null;
|
386
403
|
poll();
|
387
404
|
}
|
data/lib/message_bus/version.rb
CHANGED
@@ -7,6 +7,8 @@
|
|
7
7
|
var callbacks, clientId, failCount, shouldLongPoll, queue, responseCallbacks, uniqueId, baseUrl;
|
8
8
|
var me, started, stopped, longPoller, pollTimeout, paused, later, jQuery, interval, chunkedBackoff;
|
9
9
|
|
10
|
+
var ajaxInProgress = false;
|
11
|
+
|
10
12
|
uniqueId = function() {
|
11
13
|
return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
12
14
|
var r, v;
|
@@ -132,7 +134,13 @@
|
|
132
134
|
return false;
|
133
135
|
};
|
134
136
|
|
135
|
-
longPoller = function(poll,data){
|
137
|
+
longPoller = function(poll, data) {
|
138
|
+
|
139
|
+
if (ajaxInProgress) {
|
140
|
+
// never allow concurrent ajax reqs
|
141
|
+
return;
|
142
|
+
}
|
143
|
+
|
136
144
|
var gotData = false;
|
137
145
|
var aborted = false;
|
138
146
|
lastAjax = new Date();
|
@@ -211,6 +219,7 @@
|
|
211
219
|
|
212
220
|
updateLastAjax();
|
213
221
|
|
222
|
+
ajaxInProgress = true;
|
214
223
|
var req = me.ajax({
|
215
224
|
url: me.baseUrl + "message-bus/" + me.clientId + "/poll" + (!longPoll ? "?dlp=t" : ""),
|
216
225
|
data: data,
|
@@ -262,6 +271,9 @@
|
|
262
271
|
}
|
263
272
|
},
|
264
273
|
complete: function() {
|
274
|
+
|
275
|
+
ajaxInProgress = false;
|
276
|
+
|
265
277
|
var interval;
|
266
278
|
try {
|
267
279
|
if (gotData || aborted) {
|
@@ -362,7 +374,8 @@
|
|
362
374
|
if (callbacks.length === 0 || hiddenTabShouldWait()) {
|
363
375
|
if(!delayPollTimeout) {
|
364
376
|
delayPollTimeout = setTimeout(function() {
|
365
|
-
delayPollTimeout = null;
|
377
|
+
delayPollTimeout = null;
|
378
|
+
poll();
|
366
379
|
}, parseInt(500 + Math.random() * 500));
|
367
380
|
}
|
368
381
|
return;
|
@@ -373,7 +386,7 @@
|
|
373
386
|
data[callbacks[i].channel] = callbacks[i].last_id;
|
374
387
|
}
|
375
388
|
|
376
|
-
me.longPoll = longPoller(poll,data);
|
389
|
+
me.longPoll = longPoller(poll, data);
|
377
390
|
};
|
378
391
|
|
379
392
|
|
@@ -381,7 +394,11 @@
|
|
381
394
|
if(document.addEventListener && 'hidden' in document){
|
382
395
|
me.visibilityEvent = global.document.addEventListener('visibilitychange', function(){
|
383
396
|
if(!document.hidden && !me.longPoll && pollTimeout){
|
397
|
+
|
384
398
|
clearTimeout(pollTimeout);
|
399
|
+
clearTimeout(delayPollTimeout);
|
400
|
+
|
401
|
+
delayPollTimeout = null;
|
385
402
|
pollTimeout = null;
|
386
403
|
poll();
|
387
404
|
}
|