diegosouzapw/OmniRoute · error

[bottleneck-patch] _startHeartbeat not found on LocalDatasto

Error message

[bottleneck-patch] _startHeartbeat not found on LocalDatastore, patch skipped

What it means

Error "[bottleneck-patch] _startHeartbeat not found on LocalDatastore, patch skipped" thrown in diegosouzapw/OmniRoute.

Source

Thrown at open-sse/services/bottleneckPatch.ts:67

 * Fixed semantics:
 *  - refresh config present, no live interval → create (delegate to the original).
 *  - refresh config present, interval alive   → keep it (interval reads storeOptions
 *    live, so updated amounts are picked up) — upstream wrongly killed it here.
 *  - refresh config absent, interval alive    → clearInterval AND null the handle.
 */
export function applyBottleneckHeartbeatPatch(): void {
  if (heartbeatPatched) return;
  heartbeatPatched = true;

  // LocalDatastore is not exported; reach its prototype through a throwaway instance.
  const probe = new Bottleneck({});
  const store = (probe as unknown as { _store: BottleneckLocalDatastore })._store;
  const proto = Object.getPrototypeOf(store) as BottleneckLocalDatastore;
  void probe.disconnect();

  const originalStartHeartbeat = proto._startHeartbeat;
  if (typeof originalStartHeartbeat !== "function") {
    console.warn("[bottleneck-patch] _startHeartbeat not found on LocalDatastore, patch skipped");
    return;
  }

  proto._startHeartbeat = function patchedStartHeartbeat(this: BottleneckLocalDatastore) {
    const opts = this.storeOptions ?? {};
    const wantsHeartbeat =
      (opts.reservoirRefreshInterval != null && opts.reservoirRefreshAmount != null) ||
      (opts.reservoirIncreaseInterval != null && opts.reservoirIncreaseAmount != null);

    if (this.heartbeat != null) {
      if (wantsHeartbeat) return; // alive and still wanted — upstream wrongly cleared it here
      clearInterval(this.heartbeat);
      this.heartbeat = null; // upstream forgot this null-out — the core of the bug
      return;
    }
    return originalStartHeartbeat.call(this);
  };

View on GitHub (pinned to a179ffed5b)

When it happens

Trigger: Thrown at open-sse/services/bottleneckPatch.ts:67 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/746f5dc21043a638. Report an issue: GitHub.