{"record":{"id":"520112ada3d0f316","repo":"santifer/career-ops","slug":"name-used-elapsedms-1000-tofixed-1-s-of","errorCode":null,"errorMessage":"${name} used ${(elapsedMs / 1000).toFixed(1)}s of its ${(budgetMs / 1000).toFixed(0)}s budget (${Math.round((elapsedMs / budgetMs) * 100)}%) — it is passing, but it is close to being killed for time","messagePattern":"(.+?) used (.+?)s of its (.+?)s budget \\((.+?)%\\) — it is passing, but it is close to being killed for time","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"test-all.mjs","lineNumber":595,"sourceCode":"    const result = run(NODE, [join(scriptTmp, scriptFile), ...args], {\n      cwd: scriptTmp,\n      stdio: ['pipe', 'pipe', 'pipe'],\n      ...(declared ? { timeout: timeoutMs } : {}),\n    });\n    const elapsedMs = Date.now() - startedAt;\n    // A budget a script can raise for itself is a place to hide in, unless\n    // something still notices it creeping. Nothing did: the reason\n    // tracker-writer-lock-tests.mjs was killed rather than flagged is that\n    // spending 29 of its 30 seconds looked exactly like spending 2 — the suite\n    // reported \"runs OK\" either way, right up to the run where it did not.\n    //\n    // So the ceiling is not the only signal any more. A script that eats most\n    // of its budget says so while it is still passing, which is the point at\n    // which someone can act. This is a WARNING rather than a failure on\n    // purpose: a loaded runner is a normal reason to be slow, and turning that\n    // into a red run would trade one false failure for another.\n    if (result !== null && elapsedMs > budgetMs * SLOW_SCRIPT_WARN_FRACTION) {\n      warn(`${name} used ${(elapsedMs / 1000).toFixed(1)}s of its ${(budgetMs / 1000).toFixed(0)}s budget `\n        + `(${Math.round((elapsedMs / budgetMs) * 100)}%) — it is passing, but it is close to being killed for time`);\n    }\n    if (result !== null) {\n      pass(`${name} runs OK`);\n    } else if (allowFail && !crashedBeforeRunning(lastRunFailure())) {\n      warn(`${name} exited with error (expected without user data)`);\n    } else if (allowFail) {\n      // allowFail says \"a non-zero exit is expected here\", never \"any outcome\n      // is fine\". A script that dies with an uncaught exception did not run at\n      // all, and reporting that as the expected failure is how #3440 sat in\n      // main: cv-sync-check.mjs threw a ReferenceError at module scope, exited\n      // 1 like a missing cv.md, and the suite printed the reassuring warning\n      // for a script that never reached a single check.\n      fail(`${name} crashed before running — allowFail covers an expected exit, not an uncaught error${formatRunFailure()}`);\n    } else {\n      // Include the child's exit status and streams. Without them a CI-only\n      // failure arrives as a bare `<name> crashed`: no stack, no assertion\n      // text, no exit code, and nothing a reader can act on.","sourceCodeStart":577,"sourceCodeEnd":613,"githubUrl":"https://github.com/santifer/career-ops/blob/e7abd431fce9348a95261acac9e0c14779c35df8/test-all.mjs#L577-L613","documentation":"test-all.mjs tracks a per-script time budget; when a script exceeds SLOW_SCRIPT_WARN_FRACTION of its budget while still passing, the runner emits a warning naming the elapsed time, the budget, and the percentage. It is deliberately a warning, not a failure, because a loaded CI runner is a normal reason for slowness and failing the run would just create a new false-failure mode.","triggerScenarios":"A test script in test-all.mjs completes successfully (result !== null) but its elapsedMs exceeds budgetMs * SLOW_SCRIPT_WARN_FRACTION — e.g. a normally-fast script run on an overloaded machine or in a slow CI container.","commonSituations":"CI runners starved of CPU, first-run cold caches (npm install, Playwright browser download), parallel jobs competing for I/O, or a genuinely slow test that is approaching the point where the runner kills it for time.","solutions":["Check the warning on the machine it came from: if it is only slow there, accept it or raise that script's budgetMs entry in the budget table.","Profile the flagged script locally (node --cpu-prof or time node script.mjs) to find accidental slowness (missing mocks, network calls, large fixtures).","Reduce the script's work: split it, add faster fixtures, or skip network-dependent sections when offline.","If the script's real work has legitimately grown, increase its budget so the warning threshold moves up with it."],"exampleFix":"// before\ncostlyNetworkCheck(); // live fetch inside a unit test script\n// after\nif (!process.env.CI_NETWORK) costlyNetworkCheck(); // skip slow path when offline","handlingStrategy":"fallback","validationCode":"const elapsed = Date.now() - start; if (elapsed > budgetMs * 0.8) console.warn(`${name} nearing time budget: ${elapsed}ms/${budgetMs}ms`);","typeGuard":null,"tryCatchPattern":"// the runner itself never throws here; consumers should treat warn output as advisory\nconst result = await runWithTimeout(script, budgetMs).catch(() => null); if (result === null) handleKill();","preventionTips":["Give each slow-growing script an explicit budget entry and revisit it when the warning fires","Profile scripts periodically instead of waiting for CI slowness","Avoid live network calls in test scripts; mock or gate behind env flags","Cache expensive fixtures between runs"],"tags":["test-runner","timeout","performance","ci"],"backgroundTag":"execution-timeout","analyzedSha":"e7abd431fce9348a95261acac9e0c14779c35df8","analyzedAt":"2026-09-16T06:35:29.214Z","contentChangedAt":"2026-09-16T06:35:29.214Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}