{"record":{"id":"393de37b7816215e","repo":"apify/crawlee","slug":"colors-yellow-label-attempt-attempt","errorCode":null,"errorMessage":"${colors.yellow(`[${label}]`)}: Attempt ${attempt + 1} of ${retries} failed, and will be retried","messagePattern":"(.+?)\\]`\\)\\}: Attempt (.+?) of (.+?) failed, and will be retried","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/cli/src/commands/CreateProjectCommand.ts","lineNumber":51,"sourceCode":"}\n\nasync function withRetries<F extends (...args: unknown[]) => unknown>(\n    func: F,\n    retries: number,\n    label: string,\n): Promise<Awaited<ReturnType<F>>> {\n    let attempt = 0;\n    let lastError: any;\n\n    while (attempt < retries) {\n        try {\n            return (await func()) as Awaited<ReturnType<F>>;\n        } catch (error: any) {\n            attempt++;\n            lastError = error;\n\n            if (attempt < retries) {\n                console.warn(\n                    `${colors.yellow(`[${label}]`)}: Attempt ${attempt + 1} of ${retries} failed, and will be retried`,\n                    error.message || error,\n                );\n            }\n\n            // Wait 2500ms + (2500 * retries) before giving up to give it some time between retries\n            await setTimeout(2500 + 2500 * attempt);\n        }\n    }\n\n    throw new Error(\n        `${colors.red(`[${label}]`)}: All ${retries} attempts failed, and will not be retried\\n\\n${\n            lastError.stack || lastError\n        }`,\n    );\n}\n\nasync function downloadTemplateFilesToDisk(template: Template, destinationDirectory: string) {","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/apify/crawlee/blob/dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c/packages/cli/src/commands/CreateProjectCommand.ts#L33-L69","documentation":"This is a retry warning emitted by the generic `withRetries` wrapper in CreateProjectCommand. When the wrapped async function (e.g. `downloadTemplateFilesToDisk` used by the `create`/template download path) throws, the wrapper catches it, logs this warning via console.warn, waits 2500ms + (2500 * retries), and calls the function again until `retries` attempts are exhausted. It is not a thrown error; it signals a transient failure that the CLI is automatically recovering from.","triggerScenarios":"A call to `withRetries(downloadTemplateFilesToDisk, ...)` (or any function wrapped by it during `create` project scaffolding) throws on an attempt where `attempt < retries` — typically a network fetch of template files failing (timeout, DNS, 5xx, socket reset) or a filesystem write error.","commonSituations":"Flaky corporate network or proxy blocking downloads of the project template from GitHub; npm registry or GitHub rate limiting; offline/VPN interruption while running `apify create`; antivirus or disk permissions intermittently blocking file writes to the target directory.","solutions":["Check network connectivity/proxy settings; if the underlying cause is fixed, retries will succeed on their own.","Inspect the trailing `error.message` printed after the warning to identify the real root cause (e.g. ENOTFOUND, 403, EACCES).","If failures are permanent, wait for the final failure after all retries and fix that root error instead of retrying.","Use a stable network or retry the CLI command later; if GitHub is rate limiting, authenticate or wait before retrying."],"exampleFix":"// before: transient network failure triggers warning\nnpx apify create my-actor   // fails mid-download behind a proxy\n\n// after: configure proxy so template download succeeds\nexport HTTPS_PROXY=http://proxy.corp.local:8080\nnpx apify create my-actor","handlingStrategy":"retry","validationCode":"// Before invoking the wrapped command, verify the network path is usable\nif (!navigator.onLine) {\n  throw new Error('Network is offline; template download will fail and retry.');\n}\nconst res = await fetch('https://api.github.com', { method: 'HEAD' });\nif (!res.ok) console.warn('Template host unreachable; retries may exhaust.');","typeGuard":null,"tryCatchPattern":"try {\n  await withRetries(() => downloadTemplateFilesToDisk(url, dir), { retries: 3, label: 'template-download' });\n} catch (err) {\n  // Only reached after all retries are exhausted\n  console.error(`Template download failed after retries: ${err.message}`);\n  process.exitCode = 1;\n}","preventionTips":["Run CLI scaffolding commands on a stable connection; avoid flaky VPNs/proxies for template downloads.","Read the `error.message` appended after each retry warning to fix the root cause instead of letting retries exhaust.","Configure HTTPS_PROXY correctly in corporate environments before running `create` commands."],"tags":["retry","network","cli","transient-failure"],"backgroundTag":"transient-network-retry-exhausted","analyzedSha":"dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c","analyzedAt":"2026-08-30T22:22:28.328Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}