Skip to content

fix(market-adapter): keep Kibana LP fetches alive under proxy connect… - #12

Open
Impulssi wants to merge 1 commit into
froooze:testfrom
Impulssi:fix/kibana-lp-fetch-stability
Open

fix(market-adapter): keep Kibana LP fetches alive under proxy connect…#12
Impulssi wants to merge 1 commit into
froooze:testfrom
Impulssi:fix/kibana-lp-fetch-stability

Conversation

@Impulssi

@Impulssi Impulssi commented Aug 24, 2026

Copy link
Copy Markdown

…ion resets

The Kibana console proxy at kibana.bitshares.dev now resets connections mid-transfer once a single search page streams enough data (observed with full _source payloads around ~8k documents, and even ~2k documents with _source: true). The LP fetcher queried with size 10000 and _source: true, so every fetch died at the availability probe — and worse, silently:

  • doKibanaRequest only listened for request-phase errors; a response stream aborted mid-body never emits 'end', so the surrounding promise stayed pending forever and fetch_lp_data hung with no error output.
  • There was no retry, so a single transient reset killed the whole fetch.

Fix

  • kibana_client: handle 'aborted'/'error' on the response stream and reject the promise, so callers fail loudly instead of hanging forever.
  • kibana_candles: request only the _source branches the field map actually reads (plus the fixed timestamp/sequence fields) instead of full documents. Restricted projections keep each page small and fast (verified live: 2000-doc pages with restricted _source return in ~1.5s where full _source aborts).
  • kibana_candles: default kibanaPageSize 10000 -> 2000.
  • kibana_candles: retry transient page failures (aborted / connection reset / timeout) with linear backoff — search_after pagination is stateless on the server, so replaying a failed page is safe.
  • buildDirectionalDocumentQuery accepts an optional sourceFields argument; omitting it keeps the legacy _source: true behavior for other callers.

Testing Notes

  • tests/test_kibana_candles.ts: new coverage for the source projection derivation, the _source wiring in the directional query (plus legacy fallback), and transient-page retry recovery.
  • npm run typecheck clean.
  • Verified live against kibana.bitshares.dev with fetch_lp_data.js (BTS/XBTSX.USDT pool 1.19.48, 2-month 1h fetch): the availability probe and both chunk fetches complete where they previously hung indefinitely.

Note: I'm new to this codebase and worked through this change with an AI
coding assistant (opencode). The bug was hit on my own live instance and
all measurements / reproduction steps are mine — but please flag anything
in the code that looks off and I'll dig in and follow up.

…ion resets

The Kibana console proxy at kibana.bitshares.dev now resets connections
mid-transfer once a single search page streams enough data (observed with
full _source payloads around ~8k documents, and even ~2k documents with
_source: true). The LP fetcher queried with size 10000 and _source: true,
so every fetch died at the availability probe — and worse, silently:

- doKibanaRequest only listened for request-phase errors; a response stream
  aborted mid-body never emits 'end', so the surrounding promise stayed
  pending forever and fetch_lp_data hung with no error output.
- There was no retry, so a single transient reset killed the whole fetch.

## Fix
- kibana_client: handle 'aborted'/'error' on the response stream and reject
  the promise, so callers fail loudly instead of hanging forever.
- kibana_candles: request only the _source branches the field map actually
  reads (plus the fixed timestamp/sequence fields) instead of full documents.
  Restricted projections keep each page small and fast (verified live:
  2000-doc pages with restricted _source return in ~1.5s where full _source
  aborts).
- kibana_candles: default kibanaPageSize 10000 -> 2000.
- kibana_candles: retry transient page failures (aborted / connection reset /
  timeout) with linear backoff — search_after pagination is stateless on the
  server, so replaying a failed page is safe.
- buildDirectionalDocumentQuery accepts an optional sourceFields argument;
  omitting it keeps the legacy _source: true behavior for other callers.

## Testing Notes
- tests/test_kibana_candles.ts: new coverage for the source projection
  derivation, the _source wiring in the directional query (plus legacy
  fallback), and transient-page retry recovery.
- npm run typecheck clean.
- Verified live against kibana.bitshares.dev with fetch_lp_data.js
  (BTS/XBTSX.USDT pool 1.19.48, 2-month 1h fetch): the availability probe
  and both chunk fetches complete where they previously hung indefinitely.
@Impulssi
Impulssi force-pushed the fix/kibana-lp-fetch-stability branch from f8aca53 to f4d779c Compare August 26, 2026 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant