{"record":{"id":"3746596dac438d49","repo":"diegosouzapw/OmniRoute","slug":"service-failed-to-start","errorCode":null,"errorMessage":"Service failed to start","messagePattern":"Service failed to start","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/lib/services/ServiceSupervisor.ts","lineNumber":283,"sourceCode":"      return await fn();\n    } finally {\n      resolve();\n    }\n  }\n\n  private async waitForHealthy(): Promise<void> {\n    const timeoutMs = this.config.healthIntervalMs * 3;\n    const deadline = Date.now() + timeoutMs;\n\n    while (Date.now() < deadline) {\n      if (this.checker.getHealth() === \"healthy\") return;\n      // A spawn failure (child 'error' event or sync throw) flips state to\n      // \"error\" — stop polling and let start() surface the explicit error\n      // status as a resolve. A health-probe failure is a different, harder\n      // condition and must reject (handled below).\n      if (this.state === \"error\") {\n        if (this.spawnFailed) return;\n        throw new Error(this.lastError ?? \"Service failed to start\");\n      }\n      await new Promise((r) => setTimeout(r, 1_000));\n    }\n    // Timeout reached without a healthy probe. The health poller may have\n    // flipped the state to \"error\" while we were waiting (FAILURE_THRESHOLD\n    // consecutive failures) — surface that instead of a degraded marker.\n    if (this.state === \"error\") {\n      if (this.spawnFailed) return;\n      throw new Error(this.lastError ?? \"Service failed to start\");\n    }\n    this.lastError = sanitizeErrorMessage(\n      `Health probe did not succeed within ${timeoutMs}ms — service may still be initializing`\n    );\n    this.emit(\"healthDegraded\", {\n      tool: this.config.tool,\n      timeoutMs,\n      lastHealth: this.checker.getHealth(),\n    });","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/services/ServiceSupervisor.ts#L265-L301","documentation":"Error \"Service failed to start\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/services/ServiceSupervisor.ts:283 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}