@firebase/storage 0.8.6 → 0.8.7-20211010221442

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -336,7 +336,9 @@ callback, timeout) {
336
336
  // Would type this as "number" but that doesn't work for Node so ¯\_(ツ)_/¯
337
337
  // TODO: find a way to exclude Node type definition for storage because storage only works in browser
338
338
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
339
- let timeoutId = null;
339
+ let retryTimeoutId = null;
340
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
341
+ let globalTimeoutId = null;
340
342
  let hitTimeout = false;
341
343
  let cancelState = 0;
342
344
  function canceled() {
@@ -350,21 +352,29 @@ callback, timeout) {
350
352
  }
351
353
  }
352
354
  function callWithDelay(millis) {
353
- timeoutId = setTimeout(() => {
354
- timeoutId = null;
355
+ retryTimeoutId = setTimeout(() => {
356
+ retryTimeoutId = null;
355
357
  f(handler, canceled());
356
358
  }, millis);
357
359
  }
360
+ function clearGlobalTimeout() {
361
+ if (globalTimeoutId) {
362
+ clearTimeout(globalTimeoutId);
363
+ }
364
+ }
358
365
  function handler(success, ...args) {
359
366
  if (triggeredCallback) {
367
+ clearGlobalTimeout();
360
368
  return;
361
369
  }
362
370
  if (success) {
371
+ clearGlobalTimeout();
363
372
  triggerCallback.call(null, success, ...args);
364
373
  return;
365
374
  }
366
375
  const mustStop = canceled() || hitTimeout;
367
376
  if (mustStop) {
377
+ clearGlobalTimeout();
368
378
  triggerCallback.call(null, success, ...args);
369
379
  return;
370
380
  }
@@ -388,14 +398,15 @@ callback, timeout) {
388
398
  return;
389
399
  }
390
400
  stopped = true;
401
+ clearGlobalTimeout();
391
402
  if (triggeredCallback) {
392
403
  return;
393
404
  }
394
- if (timeoutId !== null) {
405
+ if (retryTimeoutId !== null) {
395
406
  if (!wasTimeout) {
396
407
  cancelState = 2;
397
408
  }
398
- clearTimeout(timeoutId);
409
+ clearTimeout(retryTimeoutId);
399
410
  callWithDelay(0);
400
411
  }
401
412
  else {
@@ -405,7 +416,7 @@ callback, timeout) {
405
416
  }
406
417
  }
407
418
  callWithDelay(0);
408
- setTimeout(() => {
419
+ globalTimeoutId = setTimeout(() => {
409
420
  hitTimeout = true;
410
421
  stop(true);
411
422
  }, timeout);
@@ -3122,7 +3133,7 @@ class FirebaseStorageImpl {
3122
3133
  }
3123
3134
 
3124
3135
  const name = "@firebase/storage";
3125
- const version = "0.8.6";
3136
+ const version = "0.8.7-20211010221442";
3126
3137
 
3127
3138
  /**
3128
3139
  * @license