pollForResult() — dead-code-hunter Function Reference
Architecture documentation for the pollForResult() function in index.ts from the dead-code-hunter codebase.
Entity Profile
Dependency Diagram
graph TD 110ea7f3_8de2_f010_244b_fee04cd36588["pollForResult()"] 2707a308_9fa9_efa8_2fbd_febf984897e5["run()"] 2707a308_9fa9_efa8_2fbd_febf984897e5 -->|calls| 110ea7f3_8de2_f010_244b_fee04cd36588 43263057_0adf_1e1f_ac60_6a6e6cb07e0e["sleep()"] 110ea7f3_8de2_f010_244b_fee04cd36588 -->|calls| 43263057_0adf_1e1f_ac60_6a6e6cb07e0e style 110ea7f3_8de2_f010_244b_fee04cd36588 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/index.ts lines 126–158
async function pollForResult(
api: DefaultApi,
idempotencyKey: string,
zipBlob: Blob
): Promise<DeadCodeAnalysisResponse> {
const startTime = Date.now();
for (let attempt = 1; attempt <= MAX_POLL_ATTEMPTS; attempt++) {
const response: DeadCodeAnalysisResponseAsync = await api.generateDeadCodeAnalysis({
idempotencyKey,
file: zipBlob,
});
if (response.status === 'completed' && response.result) {
return response.result;
}
if (response.status === 'failed') {
throw new Error(`Analysis job failed: ${response.error || 'unknown error'}`);
}
const elapsed = Date.now() - startTime;
if (elapsed >= POLL_TIMEOUT_MS) {
throw new Error(`Analysis timed out after ${Math.round(elapsed / 1000)}s (job: ${response.jobId})`);
}
const retryMs = (response.retryAfter ?? DEFAULT_RETRY_INTERVAL_MS / 1000) * 1000;
core.info(`Job ${response.jobId} status: ${response.status} (attempt ${attempt}/${MAX_POLL_ATTEMPTS}, retry in ${retryMs / 1000}s)`);
await sleep(retryMs);
}
throw new Error(`Analysis did not complete within ${MAX_POLL_ATTEMPTS} polling attempts`);
}
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does pollForResult() do?
pollForResult() is a function in the dead-code-hunter codebase.
What does pollForResult() call?
pollForResult() calls 1 function(s): sleep.
What calls pollForResult()?
pollForResult() is called by 1 function(s): run.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free