@swype-org/react-sdk 0.2.173 → 0.2.174

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.js CHANGED
@@ -1992,6 +1992,7 @@ var DEFAULT_POLL_INTERVAL_MS = 2e3;
1992
1992
  var DEFAULT_MAX_ATTEMPTS = 60;
1993
1993
  var DEFAULT_REQUEST_TIMEOUT_MS = 8e3;
1994
1994
  var DEFAULT_MAX_CONSECUTIVE_ERRORS = 5;
1995
+ var DEFAULT_ERROR_GRACE_PERIOD_MS = 6e4;
1995
1996
  var DEFAULT_LOG_EVERY_N_ATTEMPTS = 5;
1996
1997
  function classifyCallsStatus(status) {
1997
1998
  if (typeof status === "number") {
@@ -2013,11 +2014,14 @@ async function pollWalletCallsStatus(walletClient, callsId, options = {}) {
2013
2014
  const maxAttempts = options.maxAttempts ?? DEFAULT_MAX_ATTEMPTS;
2014
2015
  const requestTimeoutMs = options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
2015
2016
  const maxConsecutiveErrors = options.maxConsecutiveErrors ?? DEFAULT_MAX_CONSECUTIVE_ERRORS;
2017
+ const errorGracePeriodMs = options.errorGracePeriodMs ?? DEFAULT_ERROR_GRACE_PERIOD_MS;
2016
2018
  const logEveryN = Math.max(1, options.logEveryNAttempts ?? DEFAULT_LOG_EVERY_N_ATTEMPTS);
2017
2019
  const sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
2020
+ const now = options.now ?? (() => Date.now());
2018
2021
  const info = options.logger?.info ?? ((m) => console.info(m));
2019
2022
  const warn = options.logger?.warn ?? ((m) => console.warn(m));
2020
2023
  const error = options.logger?.error ?? ((m) => console.error(m));
2024
+ const pollStartedAt = now();
2021
2025
  let consecutiveErrors = 0;
2022
2026
  let lastStatus;
2023
2027
  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
@@ -2037,9 +2041,15 @@ async function pollWalletCallsStatus(walletClient, callsId, options = {}) {
2037
2041
  consecutiveErrors += 1;
2038
2042
  const message = err instanceof Error ? err.message : String(err);
2039
2043
  const isTimeout = err instanceof PromiseTimeoutError;
2044
+ const elapsedMs = now() - pollStartedAt;
2045
+ const inGracePeriod = elapsedMs < errorGracePeriodMs;
2040
2046
  warn(
2041
- `[blink-sdk][batch-wallet-calls] wallet_getCallsStatus errored. callsId=${callsId}, attempt=${attempt}, consecutiveErrors=${consecutiveErrors}, isTimeout=${isTimeout}, error=${message}`
2047
+ `[blink-sdk][batch-wallet-calls] wallet_getCallsStatus errored. callsId=${callsId}, attempt=${attempt}, consecutiveErrors=${consecutiveErrors}, isTimeout=${isTimeout}, inGracePeriod=${inGracePeriod}, elapsedMs=${elapsedMs}, error=${message}`
2042
2048
  );
2049
+ if (inGracePeriod) {
2050
+ consecutiveErrors = 0;
2051
+ continue;
2052
+ }
2043
2053
  if (consecutiveErrors >= maxConsecutiveErrors) {
2044
2054
  error(
2045
2055
  `[blink-sdk][batch-wallet-calls] Aborting poll after ${consecutiveErrors} consecutive errors. callsId=${callsId}, attempt=${attempt}, lastError=${message}`