openxiangda 1.0.115 → 1.0.117

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.
@@ -32692,6 +32692,33 @@ import {
32692
32692
  } from "react";
32693
32693
 
32694
32694
  // packages/sdk/src/runtime/core/fetch.ts
32695
+ var sleep2 = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
32696
+ var isTransientFetchError = (error) => {
32697
+ const anyError = error;
32698
+ const message3 = String(anyError?.message || error || "").toLowerCase();
32699
+ const causeCode = String(anyError?.cause?.code || "").toLowerCase();
32700
+ return causeCode === "und_err_connect_timeout" || message3.includes("und_err_connect_timeout") || message3.includes("connect_timeout") || message3.includes("econnreset") || message3.includes("socket hang up") || message3.includes("network socket disconnected") || message3.includes("fetch failed");
32701
+ };
32702
+ var fetchWithTransientRetry = async (fetchImpl, input, init, options = {}) => {
32703
+ if (!options.enabled) {
32704
+ return fetchImpl(input, init);
32705
+ }
32706
+ const retries = Number.isFinite(Number(options.retries)) ? Number(options.retries) : 2;
32707
+ const baseDelayMs = Number.isFinite(Number(options.baseDelayMs)) ? Number(options.baseDelayMs) : 250;
32708
+ let lastError;
32709
+ for (let attempt = 0; attempt <= retries; attempt += 1) {
32710
+ try {
32711
+ return await fetchImpl(input, init);
32712
+ } catch (error) {
32713
+ lastError = error;
32714
+ if (attempt >= retries || !isTransientFetchError(error)) {
32715
+ throw error;
32716
+ }
32717
+ await sleep2(Math.min(baseDelayMs * Math.pow(2, attempt), 2e3));
32718
+ }
32719
+ }
32720
+ throw lastError;
32721
+ };
32695
32722
  var createBoundFetch = (fetchImpl) => {
32696
32723
  const baseFetch = fetchImpl || globalThis.fetch;
32697
32724
  return ((input, init) => baseFetch.call(globalThis, input, init));
@@ -32714,6 +32741,12 @@ var normalizeMethod2 = (method4) => {
32714
32741
  const value = String(method4 || "get").toUpperCase();
32715
32742
  return ["GET", "POST", "PUT", "DELETE", "PATCH"].includes(value) ? value : "GET";
32716
32743
  };
32744
+ var shouldRetryTransportRequest = (payload) => {
32745
+ const method4 = normalizeMethod2(payload?.method);
32746
+ if (method4 === "GET") return true;
32747
+ const path = String(payload?.path || "").split("?")[0];
32748
+ return method4 === "POST" && path === "/workflow/capabilities/resolve";
32749
+ };
32717
32750
  var normalizeEnvelopeCode2 = (value, fallback) => {
32718
32751
  if (value === void 0 || value === null || value === "") return fallback;
32719
32752
  const normalized = Number(value);
@@ -32768,11 +32801,13 @@ var createBrowserPageBridge = (options = {}) => {
32768
32801
  body = JSON.stringify(payload.body);
32769
32802
  }
32770
32803
  }
32771
- const response = await fetchImpl(url2, {
32804
+ const response = await fetchWithTransientRetry(fetchImpl, url2, {
32772
32805
  method: normalizeMethod2(payload.method),
32773
32806
  headers,
32774
32807
  body,
32775
32808
  credentials: "include"
32809
+ }, {
32810
+ enabled: shouldRetryTransportRequest(payload)
32776
32811
  });
32777
32812
  return parseJsonResponse(response);
32778
32813
  };