MCPcopy Index your code
hub / github.com/devcontainers/cli / retry

Function retry

src/spec-node/utils.ts:41–58  ·  view source on GitHub ↗
(fn: () => Promise<T>, options: { retryIntervalMilliseconds: number; maxRetries: number; output: Log })

Source from the content-addressed store, hash-verified

39
40// Generic retry function
41export async function retry<T>(fn: () => Promise<T>, options: { retryIntervalMilliseconds: number; maxRetries: number; output: Log }): Promise<T> {
42 const { retryIntervalMilliseconds, maxRetries, output } = options;
43 let lastError: Error | undefined;
44 for (let i = 0; i < maxRetries; i++) {
45 try {
46 return await fn();
47 } catch (err) {
48 lastError = err;
49 output.write(
50 `Retrying (Attempt ${i}) with error
51 '${toErrorText(String(err && (err.stack || err.message) || err))}'`,
52 LogLevel.Warning
53 );
54 await new Promise(resolve => setTimeout(resolve, retryIntervalMilliseconds));
55 }
56 }
57 throw lastError;
58}
59
60export async function uriToWSLFsPath(uri: URI, cliHost: CLIHost): Promise<string> {
61 if (uri.scheme === 'file' && cliHost.type === 'wsl') {

Callers 1

inspectDockerImageFunction · 0.85

Calls 2

toErrorTextFunction · 0.85
writeMethod · 0.65

Tested by

no test coverage detected