Skip to content

fix(limitless): throw on watchOrderBook failure instead of silent swallow#1581

Merged
realfishsam merged 2 commits into
pmxt-dev:mainfrom
AbhilashG12:fix/limitless-ws-error-handling
Jul 10, 2026
Merged

fix(limitless): throw on watchOrderBook failure instead of silent swallow#1581
realfishsam merged 2 commits into
pmxt-dev:mainfrom
AbhilashG12:fix/limitless-ws-error-handling

Conversation

@AbhilashG12

Copy link
Copy Markdown
Contributor

Description

Fixes #676 and closes #1374.

The watchOrderBook method for Limitless was previously catching all SDK/network errors and silently returning an empty orderbook. This caused two severe issues:

  1. Upstream stream loops (streamSingle) would spin infinitely at max CPU.
  2. Downstream trading logic received false "zero liquidity" signals instead of feed degradation alerts.

This PR removes the empty fallback. It now properly logs the error (including the market context as requested in #1374) and throws it, forcing the caller to handle the failure and allowing circuit breakers / reconnect logic to function normally.

@realfishsam

Copy link
Copy Markdown
Contributor

PR Review: FAIL

What This Does

Attempts to make Limitless watchOrderBook throw instead of returning fake empty liquidity when the WebSocket/snapshot path fails. That matters because SDK consumers should not mistake transport failure for an empty order book.

Blast Radius

Limitless WebSocket order-book path in core/src/exchanges/limitless/websocket.ts; no schema or SDK wrapper signature changes.

Consumer Verification

Before (base branch):
Static consumer-path trace: when the timeout fallback fetchOrderBookSnapshot() failed, watchOrderBook() logged a warning and resolved getEmptyOrderbook(), so a consumer could receive empty bids/asks for a transport/API failure.

After (PR branch):
The outer catch now throws, but the timeout fallback still catches its own snapshot error and resolves this.getEmptyOrderbook() at core/src/exchanges/limitless/websocket.ts:186-189. That means the concrete failure path in the PR title still returns fake empty liquidity instead of throwing.

Test Results

  • Build: PASS for current main core build during scheduled run
  • Unit tests: PASS for current main core Jest (699 passed, 3 skipped)
  • Server starts: NOT VERIFIED for this PR head
  • E2E smoke: FAIL by static consumer-path trace for timeout fallback failure

Findings

  1. core/src/exchanges/limitless/websocket.ts:186-189 — the timeout fallback still swallows fetchOrderBookSnapshot() failures and resolves getEmptyOrderbook(). The new outer catch at lines 195-202 cannot see this because the inner promise resolves successfully, so watchOrderBook() still reports an empty order book for this failure mode.

PMXT Pipeline Check

  • Field propagation (3-layer): N/A
  • OpenAPI sync: N/A
  • Financial precision: OK/N/A
  • Type safety: OK
  • Auth safety: N/A

Semver Impact

patch -- bug fix intent, but incomplete.

Risk

If merged as-is, sparse Limitless WS updates plus REST snapshot failure can still produce false zero-liquidity order books for SDK consumers.

@realfishsam realfishsam merged commit 4283ddd into pmxt-dev:main Jul 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants