@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.
@@ -345,7 +345,9 @@ callback, timeout) {
345
345
  // Would type this as "number" but that doesn't work for Node so ¯\_(ツ)_/¯
346
346
  // TODO: find a way to exclude Node type definition for storage because storage only works in browser
347
347
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
348
- let timeoutId = null;
348
+ let retryTimeoutId = null;
349
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
350
+ let globalTimeoutId = null;
349
351
  let hitTimeout = false;
350
352
  let cancelState = 0;
351
353
  function canceled() {
@@ -359,21 +361,29 @@ callback, timeout) {
359
361
  }
360
362
  }
361
363
  function callWithDelay(millis) {
362
- timeoutId = setTimeout(() => {
363
- timeoutId = null;
364
+ retryTimeoutId = setTimeout(() => {
365
+ retryTimeoutId = null;
364
366
  f(handler, canceled());
365
367
  }, millis);
366
368
  }
369
+ function clearGlobalTimeout() {
370
+ if (globalTimeoutId) {
371
+ clearTimeout(globalTimeoutId);
372
+ }
373
+ }
367
374
  function handler(success, ...args) {
368
375
  if (triggeredCallback) {
376
+ clearGlobalTimeout();
369
377
  return;
370
378
  }
371
379
  if (success) {
380
+ clearGlobalTimeout();
372
381
  triggerCallback.call(null, success, ...args);
373
382
  return;
374
383
  }
375
384
  const mustStop = canceled() || hitTimeout;
376
385
  if (mustStop) {
386
+ clearGlobalTimeout();
377
387
  triggerCallback.call(null, success, ...args);
378
388
  return;
379
389
  }
@@ -397,14 +407,15 @@ callback, timeout) {
397
407
  return;
398
408
  }
399
409
  stopped = true;
410
+ clearGlobalTimeout();
400
411
  if (triggeredCallback) {
401
412
  return;
402
413
  }
403
- if (timeoutId !== null) {
414
+ if (retryTimeoutId !== null) {
404
415
  if (!wasTimeout) {
405
416
  cancelState = 2;
406
417
  }
407
- clearTimeout(timeoutId);
418
+ clearTimeout(retryTimeoutId);
408
419
  callWithDelay(0);
409
420
  }
410
421
  else {
@@ -414,7 +425,7 @@ callback, timeout) {
414
425
  }
415
426
  }
416
427
  callWithDelay(0);
417
- setTimeout(() => {
428
+ globalTimeoutId = setTimeout(() => {
418
429
  hitTimeout = true;
419
430
  stop(true);
420
431
  }, 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