@firebase/util 1.11.0-firebase-studio-sdk-integration.0615f555a → 1.11.0-firebase-studio-sdk-integration.12759bc2e

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.
package/dist/index.cjs.js CHANGED
@@ -694,16 +694,37 @@ class Deferred {
694
694
  function isCloudWorkstation(host) {
695
695
  return host.endsWith('.cloudworkstations.dev');
696
696
  }
697
+ const pingQueue = {};
698
+ const MAX_PING_RETRIES = 10;
697
699
  /**
698
700
  * Makes a fetch request to the given server.
699
701
  * Mostly used for forwarding cookies in Firebase Studio.
700
702
  * @public
701
703
  */
702
704
  async function pingServer(endpoint) {
703
- const result = await fetch(endpoint, {
704
- credentials: 'include'
705
- });
706
- return result.ok;
705
+ if (pingQueue[endpoint]) {
706
+ return Promise.resolve(false);
707
+ }
708
+ pingQueue[endpoint] = true;
709
+ function waitFor(ms) {
710
+ return new Promise((resolve, reject) => {
711
+ setTimeout(resolve);
712
+ });
713
+ }
714
+ for (let i = 0; i < MAX_PING_RETRIES; i++) {
715
+ try {
716
+ await waitFor(i * 1000);
717
+ const result = await fetch(endpoint, {
718
+ credentials: 'include'
719
+ });
720
+ if (result.ok) {
721
+ return result.ok;
722
+ }
723
+ }
724
+ catch (_a) { }
725
+ }
726
+ delete pingQueue[endpoint];
727
+ return false;
707
728
  }
708
729
 
709
730
  /**