MCPcopy
hub / github.com/simstudioai/sim / sendWithRetry

Function sendWithRetry

packages/runtime-secrets/src/index.ts:66–89  ·  view source on GitHub ↗
(
  client: SecretsManagerClient,
  secretId: string
)

Source from the content-addressed store, hash-verified

64}
65
66async function sendWithRetry(
67 client: SecretsManagerClient,
68 secretId: string
69): Promise<GetSecretValueCommandOutput> {
70 let lastError: unknown
71 for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
72 try {
73 return await client.send(new GetSecretValueCommand({ SecretId: secretId }), {
74 abortSignal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
75 })
76 } catch (error) {
77 lastError = error
78 if (attempt < MAX_ATTEMPTS) {
79 const delay = backoffWithJitter(attempt, null, { baseMs: 200, maxMs: 2000 })
80 logger.warn(
81 `Failed to fetch runtime secrets (attempt ${attempt}/${MAX_ATTEMPTS}), retrying`,
82 { error: getErrorMessage(error) }
83 )
84 await sleep(delay)
85 }
86 }
87 }
88 throw new Error(`Failed to fetch runtime secrets from ${secretId}: ${getErrorMessage(lastError)}`)
89}
90
91function parseSecretJson(secretString: string): Record<string, unknown> {
92 let parsed: unknown

Callers 1

fetchSecretStringFunction · 0.85

Calls 5

backoffWithJitterFunction · 0.90
getErrorMessageFunction · 0.90
sleepFunction · 0.90
sendMethod · 0.80
warnMethod · 0.65

Tested by

no test coverage detected