{"record":{"id":"746f5dc21043a638","repo":"diegosouzapw/OmniRoute","slug":"bottleneck-patch-startheartbeat-not-found-on-lo","errorCode":null,"errorMessage":"[bottleneck-patch] _startHeartbeat not found on LocalDatastore, patch skipped","messagePattern":"\\[bottleneck-patch\\] _startHeartbeat not found on LocalDatastore, patch skipped","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"open-sse/services/bottleneckPatch.ts","lineNumber":67,"sourceCode":" * Fixed semantics:\n *  - refresh config present, no live interval → create (delegate to the original).\n *  - refresh config present, interval alive   → keep it (interval reads storeOptions\n *    live, so updated amounts are picked up) — upstream wrongly killed it here.\n *  - refresh config absent, interval alive    → clearInterval AND null the handle.\n */\nexport function applyBottleneckHeartbeatPatch(): void {\n  if (heartbeatPatched) return;\n  heartbeatPatched = true;\n\n  // LocalDatastore is not exported; reach its prototype through a throwaway instance.\n  const probe = new Bottleneck({});\n  const store = (probe as unknown as { _store: BottleneckLocalDatastore })._store;\n  const proto = Object.getPrototypeOf(store) as BottleneckLocalDatastore;\n  void probe.disconnect();\n\n  const originalStartHeartbeat = proto._startHeartbeat;\n  if (typeof originalStartHeartbeat !== \"function\") {\n    console.warn(\"[bottleneck-patch] _startHeartbeat not found on LocalDatastore, patch skipped\");\n    return;\n  }\n\n  proto._startHeartbeat = function patchedStartHeartbeat(this: BottleneckLocalDatastore) {\n    const opts = this.storeOptions ?? {};\n    const wantsHeartbeat =\n      (opts.reservoirRefreshInterval != null && opts.reservoirRefreshAmount != null) ||\n      (opts.reservoirIncreaseInterval != null && opts.reservoirIncreaseAmount != null);\n\n    if (this.heartbeat != null) {\n      if (wantsHeartbeat) return; // alive and still wanted — upstream wrongly cleared it here\n      clearInterval(this.heartbeat);\n      this.heartbeat = null; // upstream forgot this null-out — the core of the bug\n      return;\n    }\n    return originalStartHeartbeat.call(this);\n  };\n","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/open-sse/services/bottleneckPatch.ts#L49-L85","documentation":"Error \"[bottleneck-patch] _startHeartbeat not found on LocalDatastore, patch skipped\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at open-sse/services/bottleneckPatch.ts:67 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"}