Skip to content

fix(rpc): narrow XDR error predicate, stop skipping on bare "unknown" - #208

Closed
makar52nn2016-jpg wants to merge 1 commit into
Miracle656:mainfrom
makar52nn2016-jpg:fix/unknown-error-classification
Closed

makar52nn2016-jpg wants to merge 1 commit into
Miracle656:mainfrom
makar52nn2016-jpg:fix/unknown-error-classification

Conversation

@makar52nn2016-jpg

Copy link
Copy Markdown

Closes #183 — fetchEventsSafe was silently skipping ledgers whenever the RPC error message contained the substring "unknown". That matched far too much: bare unknown error, getaddrinfo ENOTFOUND … unknown host, provider 5xx bodies. A transient network blip was indistinguishable from a genuinely unindexable ledger, and the cursor would advance past it without anything but a console.warn.

What changed

  • New isXdrDecodeError(err) predicate covers the real XDR failure cases (SDK decoder messages containing "xdr", Soroban-specific "unknown scval type" / "unknown scaddress type" / "unknown soroban") and only those. Network blips, 5xx bodies, and bare "unknown" no longer match.
  • fetchEventsSafe calls the predicate instead of the substring check in both the single-ledger branch (line ~209) and the multi-ledger bisection branch (line ~222).
  • New ledgers_skipped_total Prometheus counter, labelled by network, increments on every XDR-skip. Skips are visible rather than only logged, so a sustained rate is alertable.

Acceptance criteria coverage

  • Classification moves to a named predicate covering the real XDR cases and not bare "unknown"
  • A transient Error("unknown error") propagates and is retried instead of skipping the ledger — fails before, passes after
  • A genuine XDR error still bisects and skips; existing fetchEventsSafe tests stay green (20/20 pass)
  • Every skipped ledger increments a metric, so skips are visible rather than only logged

Tests

src/__tests__/fetchEventsSafe.test.ts adds 13 new cases:

  • isXdrDecodeError returns true for SDK decoder errors + Soroban unknown-type errors; false for bare "unknown", "unknown host", 5xx bodies, plain network errors, nullish inputs. Case-insensitive.
  • fetchEventsSafe re-throws bare "unknown error" instead of skipping
  • fetchEventsSafe re-throws "getaddrinfo ENOTFOUND … unknown host" instead of skipping
  • fetchEventsSafe still skips a genuine XDR error on single-ledger range AND increments the new skip metric
  • fetchEventsSafe still bisects genuine XDR errors on multi-ledger ranges
  • fetchEventsSafe increments skipped-ledger metric for every XDR-skipped ledger
npx tsc --noEmit         # no errors
npx jest src/__tests__/fetchEventsSafe.test.ts  # 20/20 pass

The Integration tests CI job is red on main and predates this PR (per the issue body, open PRs #177 and #178 address it). If that job is red here too, it is not from these changes.

Bounty: Stellar Wave — Drips Wave — 150 points

Closes Miracle656#183 — fetchEventsSafe was silently skipping ledgers whenever the
RPC error message contained the substring "unknown". That matched far
too much: bare `unknown error`, `getaddrinfo ENOTFOUND … unknown host`,
provider 5xx bodies. A transient network blip was indistinguishable from
a genuinely unindexable ledger, and the cursor would advance past it
without anything but a `console.warn`.

## What changed

- New `isXdrDecodeError(err)` predicate covers the real XDR failure
  cases (SDK decoder messages containing "xdr", Soroban-specific
  "unknown scval type" / "unknown scaddress type" / "unknown soroban")
  and only those. Network blips, 5xx bodies, and bare "unknown" no
  longer match.
- `fetchEventsSafe` calls the predicate instead of the substring check
  in both the single-ledger branch (line ~209) and the multi-ledger
  bisection branch (line ~222).
- New `ledgers_skipped_total` Prometheus counter, labelled by network,
  increments on every XDR-skip. Skips are visible rather than only
  logged, so a sustained rate is alertable.

## Acceptance criteria coverage

- [x] Classification moves to a named predicate covering the real XDR
      cases and *not* bare "unknown"
- [x] A transient `Error("unknown error")` propagates and is retried
      instead of skipping the ledger — fails before, passes after
- [x] A genuine XDR error still bisects and skips; existing
      `fetchEventsSafe` tests stay green (20/20 pass)
- [x] Every skipped ledger increments a metric, so skips are visible
      rather than only logged

## Tests

`src/__tests__/fetchEventsSafe.test.ts` adds 13 new cases:

- `isXdrDecodeError` returns true for SDK decoder errors + Soroban
  unknown-type errors; false for bare "unknown", "unknown host",
  5xx bodies, plain network errors, nullish inputs. Case-insensitive.
- `fetchEventsSafe` re-throws bare "unknown error" instead of skipping
- `fetchEventsSafe` re-throws "getaddrinfo ENOTFOUND … unknown host"
  instead of skipping
- `fetchEventsSafe` still skips a genuine XDR error on single-ledger
  range AND increments the new skip metric
- `fetchEventsSafe` still bisects genuine XDR errors on multi-ledger
  ranges
- `fetchEventsSafe` increments skipped-ledger metric for every
  XDR-skipped ledger

Bounty: Stellar Wave — Drips Wave — 150 points
@makar52nn2016-jpg

Copy link
Copy Markdown
Author

Closing this PR.

Issue #183 is assigned to @JemimahEkong through the official Stellar Wave program workflow (application accepted on 2026-09-26, due 2026-09-30). I missed the application step and submitted this PR directly — that was incorrect. Maintainer's review queue should focus on the assigned contributor's work.

Apologies for the noise.

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.

Stop treating any error containing "unknown" as an XDR failure

1 participant