{"record":{"id":"4c770fb5bf8a75ed","repo":"windmill-labs/windmill","slug":"test-execution-timed-out-after-60-seconds","errorCode":null,"errorMessage":"Test execution timed out after 60 seconds","messagePattern":"Test execution timed out after 60 seconds","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/chat/shared.ts","lineNumber":1603,"sourceCode":"\t\t\t\tstatus: deriveChatJobStatus(fetchedJob),\n\t\t\t\tjob: trimJob(fetchedJob)\n\t\t\t})\n\t\t} catch (error) {\n\t\t\tif (!detachEnabled && attempts >= maxAttempts) {\n\t\t\t\tthrow error\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!job) {\n\t\tif (detachEnabled) {\n\t\t\treturn 'detached'\n\t\t}\n\t\ttoolCallbacks.setToolStatus(toolId, {\n\t\t\tcontent: 'Test timed out',\n\t\t\terror: 'Execution timed out or failed to complete'\n\t\t})\n\t\tthrow new Error('Test execution timed out after 60 seconds')\n\t}\n\n\treturn job\n}\n\n// Helper function to extract code blocks from markdown text\nexport function extractCodeFromMarkdown(markdown: string): string[] {\n\tconst codeBlocks: string[] = []\n\n\t// Matches: ```[language]\\n[code]\\n```\n\tconst codeBlockRegex = /```(?:[a-z]+)?\\n([\\s\\S]*?)```/g\n\n\tlet match: RegExpExecArray | null = null\n\twhile ((match = codeBlockRegex.exec(markdown)) !== null) {\n\t\tconst code = match[1].trim()\n\t\tif (code) {\n\t\t\tcodeBlocks.push(code)\n\t\t}","sourceCodeStart":1585,"sourceCodeEnd":1621,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/shared.ts#L1585-L1621","documentation":"The copilot's test-run helper polls a script/flow test job and gives up after 60 seconds; on timeout it throws 'Test execution timed out after 60 seconds'. It also records a 'Test timed out' tool status with the message 'Execution timed out or failed to complete' so both user and model see the failure.","triggerScenarios":"A test run was queued successfully but the job had not reached a terminal state (success/failure) within the 60-second window — long-running script code, an infinite loop, a flow step waiting on a slow external API, a worker not picking up the job, or the poll loop's detached/abort branch being hit.","commonSituations":"Script calls a slow third-party API and exceeds 60s; flow contains a sleep or retry step; no worker available for the runtimes so the job stays queued; heavy queue backlog on a busy instance; debugging code with an accidental while(true).","solutions":["Open the run in the Runs view to see whether it eventually finished or is stuck, and inspect the slow step.","Shorten or optimize the tested code (add timeouts to external calls, remove sleeps) so it completes under 60s.","Check that a worker is running and the queue is not backed up (jobs stuck in 'waiting').","Re-run the test from the chat after fixing; if legitimately long-running, test the piece in isolation instead of the whole flow.","If the job never started, check backend logs for scheduler/worker errors."],"exampleFix":"// before (code under test hangs)\nconst data = await fetch('https://slow-api.example.com') // >60s\n// after\nconst data = await fetchWithTimeout('https://slow-api.example.com', 10_000)","handlingStrategy":"try-catch","validationCode":"// sanity-check the code under test before running\nif (/while\\s*\\(\\s*true\\s*\\)/.test(code)) console.warn('possible infinite loop; test may hit the 60s timeout')","typeGuard":null,"tryCatchPattern":"try {\n  await runTest(job)\n} catch (e) {\n  if (e.message === 'Test execution timed out after 60 seconds') {\n    // inspect run status out-of-band; do not blind-retry until the slow step is fixed\n  }\n}","preventionTips":["Add explicit timeouts to external HTTP/DB calls inside tested scripts.","Keep test payloads small; test heavy logic in isolation.","Ensure workers are running and the queue is healthy before long test runs.","Avoid sleeps and retry loops in code intended for quick test iterations."],"tags":["timeout","test-run","copilot","job-execution"],"backgroundTag":"operation-timed-out","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}