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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b2c8ffc1228b2e50751a6671ce91e12239e22cf3
4
- data.tar.gz: 76b8c24586fa1781acd95dd352b269cf4a21bf99
3
+ metadata.gz: ab4e02e88e557c6eeeedbe109bdcde769d139ea8
4
+ data.tar.gz: 39009dd918e0218b44817bcbe76af71f7dc756d4
5
5
  SHA512:
6
- metadata.gz: 2f17a8234add27233c63619a73bf214b38c53cb5e4938f61b7b13a1d3fd605f20bb335d213f5c0202a4f6358d0dfd982bf38a8079571e77ffce3fb67eb0d7245
7
- data.tar.gz: 5815b33e4f0cce2de16ac2bd6836bbb2eb1d115fb87818e00a35cc571841fdcff36125453d9c24bab725004941c9ef861aaa683d5c5c728edd18fff50c3fc34b
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
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
 
@@ -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; poll();
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
  }
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module MessageBus
3
- VERSION = "2.1.3"
3
+ VERSION = "2.1.4"
4
4
  end
@@ -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; poll();
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
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: message_bus
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 2.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron