@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.
@@ -337,7 +337,9 @@ callback, timeout) {
337
337
  // Would type this as "number" but that doesn't work for Node so ¯\_(ツ)_/¯
338
338
  // TODO: find a way to exclude Node type definition for storage because storage only works in browser
339
339
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
340
- let timeoutId = null;
340
+ let retryTimeoutId = null;
341
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
342
+ let globalTimeoutId = null;
341
343
  let hitTimeout = false;
342
344
  let cancelState = 0;
343
345
  function canceled() {
@@ -351,21 +353,29 @@ callback, timeout) {
351
353
  }
352
354
  }
353
355
  function callWithDelay(millis) {
354
- timeoutId = setTimeout(() => {
355
- timeoutId = null;
356
+ retryTimeoutId = setTimeout(() => {
357
+ retryTimeoutId = null;
356
358
  f(handler, canceled());
357
359
  }, millis);
358
360
  }
361
+ function clearGlobalTimeout() {
362
+ if (globalTimeoutId) {
363
+ clearTimeout(globalTimeoutId);
364
+ }
365
+ }
359
366
  function handler(success, ...args) {
360
367
  if (triggeredCallback) {
368
+ clearGlobalTimeout();
361
369
  return;
362
370
  }
363
371
  if (success) {
372
+ clearGlobalTimeout();
364
373
  triggerCallback.call(null, success, ...args);
365
374
  return;
366
375
  }
367
376
  const mustStop = canceled() || hitTimeout;
368
377
  if (mustStop) {
378
+ clearGlobalTimeout();
369
379
  triggerCallback.call(null, success, ...args);
370
380
  return;
371
381
  }
@@ -389,14 +399,15 @@ callback, timeout) {
389
399
  return;
390
400
  }
391
401
  stopped = true;
402
+ clearGlobalTimeout();
392
403
  if (triggeredCallback) {
393
404
  return;
394
405
  }
395
- if (timeoutId !== null) {
406
+ if (retryTimeoutId !== null) {
396
407
  if (!wasTimeout) {
397
408
  cancelState = 2;
398
409
  }
399
- clearTimeout(timeoutId);
410
+ clearTimeout(retryTimeoutId);
400
411
  callWithDelay(0);
401
412
  }
402
413
  else {
@@ -406,7 +417,7 @@ callback, timeout) {
406
417
  }
407
418
  }
408
419
  callWithDelay(0);
409
- setTimeout(() => {
420
+ globalTimeoutId = setTimeout(() => {
410
421
  hitTimeout = true;
411
422
  stop(true);
412
423
  }, timeout);
@@ -3114,7 +3125,7 @@ class FirebaseStorageImpl {
3114
3125
  }
3115
3126
 
3116
3127
  const name = "@firebase/storage";
3117
- const version = "0.8.6";
3128
+ const version = "0.8.7-20211010221442";
3118
3129
 
3119
3130
  /**
3120
3131
  * @license