Skip to content

feat: indexer feature flag startup check, readiness latency, route-safe error mapping#259

Merged
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
davedumto:chore/indexer-flags-readiness-error-mapping
Apr 28, 2026
Merged

feat: indexer feature flag startup check, readiness latency, route-safe error mapping#259
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
davedumto:chore/indexer-flags-readiness-error-mapping

Conversation

@davedumto
Copy link
Copy Markdown
Contributor

Summary

Bundles three small, scoped server changes from the Stellar Wave queue:

  • Add shared helper for route-safe unknown error mapping #245 — route-safe unknown error mapping helper
    Adds mapUnknownRouteError() in src/utils/route-error.utils.ts and wires it into the global error middleware fallback path. The helper embeds the X-Request-ID for log correlation and hides internals (message/stack/raw error) in production. Existing dedicated branches for Zod, JWT, Prisma, ApiError, payload-too-large and malformed JSON are unchanged.
  • Add readiness check latency field to response metadata #242 — readiness latency in response metadata
    GET /api/v1/health/ready now returns a top-level latencyMs field measuring the total readiness probe duration. Per-check latencyMs is preserved. Payload remains public-safe.
  • Add startup check for required indexer feature flags #213 — startup check for required indexer feature flags
    Adds ENABLE_INDEXER_DEDUPE, ENABLE_INDEXER_DLQ, ENABLE_INDEXER_CURSOR_STALENESS_WARNING env flags and a centralized validator (runIndexerFeatureFlagsStartupCheck) called from server.ts before DB connect. Cross-field invariants (e.g. DLQ requires dedupe; staleness flag requires a sane threshold) are aggregated into a single actionable error and the process exits 1 on misconfiguration.

Tests

  • 22 new Jest specs across route-error.utils.test.ts, health.controllers.test.ts and indexer-flags-startup-check.utils.test.ts — all green.
  • tsc --noEmit clean. ESLint clean on changed files.

Test plan

  • pnpm exec jest src/utils/route-error.utils.test.ts src/modules/health/health.controllers.test.ts src/utils/indexer-flags-startup-check.utils.test.ts passes
  • pnpm exec tsc --noEmit is clean
  • curl localhost:3000/api/v1/health/ready includes a numeric top-level latencyMs
  • Setting ENABLE_INDEXER_DLQ=true ENABLE_INDEXER_DEDUPE=false pnpm dev refuses to start with a logged issues list

Closes

closes #245
closes #242
closes #213

…fe error mapping

- Add shared mapUnknownRouteError helper for the global error-middleware
  fallback path, embedding the request id for log correlation and hiding
  internals in production. Known-error branches (Zod, JWT, Prisma,
  ApiError, payload-too-large, malformed JSON) are unchanged.
- Surface a top-level latencyMs field on GET /api/v1/health/ready
  measuring the total readiness probe duration. Per-check latency is
  preserved.
- Introduce ENABLE_INDEXER_DEDUPE, ENABLE_INDEXER_DLQ and
  ENABLE_INDEXER_CURSOR_STALENESS_WARNING flags plus a centralized
  startup validator that aggregates every cross-field invariant breach
  into one actionable error and exits with code 1 on misconfiguration.
- Add Jest tests for each helper and short docs covering the new
  envelope, the readiness metadata field and the indexer flag matrix.
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 28, 2026

@davedumto Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Chucks1093 Chucks1093 merged commit 07a58f7 into accesslayerorg:main Apr 28, 2026
1 check 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