Skip to content

feat: error-context helper, DB pool startup log, last-page cursor test, indexer retry docs#322

Merged
Chucks1093 merged 2 commits into
accesslayerorg:mainfrom
tosin-zoffun:feat/issues-297-298-301-302
May 28, 2026
Merged

feat: error-context helper, DB pool startup log, last-page cursor test, indexer retry docs#322
Chucks1093 merged 2 commits into
accesslayerorg:mainfrom
tosin-zoffun:feat/issues-297-298-301-302

Conversation

@tosin-zoffun

Copy link
Copy Markdown
Contributor

Summary

Four small, independent improvements.

#302 — Structured error context helper

Adds buildErrorContext(err, options) in src/utils/error-context.utils.ts: produces a consistent { name, message, code, requestId?, stack?, timestamp } from any caught value (Error subclasses, Prisma P* errors, Zod/JWT by name, plain strings). The error code is normalized to the shared ErrorCode values, and the stack is debug-only (omitted unless includeStack). Applied in the global error middleware's structured log so the request id and normalized code are logged together.

#298 — Startup log for DB connection pool config

describeDatabasePoolConfig() parses DATABASE_URL for the pool settings Prisma reads (connection_limit, pool_timeout, connect_timeout) plus the query-timeout, and server.ts logs them right after prisma.$connect()before the server accepts requests. No credentials or host details are included (parsing failures degrade to 'default').

#301 — Integration test: cursor → partial last page

The existing cursor round-trip test covers an even split (6 items / two full pages). This adds creator-list-last-page.integration.test.ts for the end-of-list edge: a known total of 5 at limit=2 yields pages [2, 2, 1]; the last page returns only the remaining item and meta.hasMore=false. A second test walks every page and asserts the traversal reconstructs the full set exactly once.

#297 — Indexer retry/backoff docs (docs-only)

Adds docs/indexer/RETRY_BACKOFF.md: documents the exponential backoff with jitter (getBackoffWithJitter: base 1000ms, ×2^attempt, cap 30000ms, jittered by INDEXER_JITTER_FACTOR), the controlling config values, and the DLQ exhaustion behavior (moveToDLQindexerDLQ, observable via getDLQDepth/syncDLQMetrics; the risk of silent loss when the DLQ is disabled).

Test plan

  • tsc --noEmit — 0 errors (after prisma generate).
  • New tests pass: error-context.utils.test.ts (6), db-pool-config.utils.test.ts (4), creator-list-last-page.integration.test.ts (2).
  • prettier --check + eslint clean on changed files (also enforced by the lint-staged pre-commit hook).
  • Full suite: no new failures introduced — passing suites 43 → 46, passing tests 365 → 377.

Notes / out of scope

  • The full jest run has 17 pre-existing failed suites / 8 failed tests on main (unrelated files, e.g. activity.service.test.ts) — confirmed identical with this change stashed; this PR introduces zero new failures. Integration tests require prisma generate first.

Closes #297
Closes #298
Closes #301
Closes #302

…t, indexer retry docs

- Add buildErrorContext() to extract a consistent, log-safe error context
  (name, message, normalized code, optional debug-only stack, requestId) from
  any caught value; use it in the global error middleware's structured log (accesslayerorg#302).
- Log the database connection-pool configuration (pool size, pool/connect
  timeouts, query timeout) at startup before accepting requests, parsed from
  DATABASE_URL with no credentials leaked (accesslayerorg#298).
- Add an integration test for the creator list cursor advancing to a partial
  last page: only the remaining item is returned and hasMore=false (accesslayerorg#301).
- Document the indexer retry policy, exponential backoff with jitter, and
  DLQ exhaustion behavior in docs/indexer/RETRY_BACKOFF.md (accesslayerorg#297).

Closes accesslayerorg#297
Closes accesslayerorg#298
Closes accesslayerorg#301
Closes accesslayerorg#302
@drips-wave

drips-wave Bot commented May 28, 2026

Copy link
Copy Markdown

@tosin-zoffun 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

…t startup

Replace the ad-hoc console.error in the global error handler with a structured
log built via buildErrorContext (request id + normalized code, stack only in
development) (accesslayerorg#302), and log the database connection pool configuration once at
startup so connection exhaustion is diagnosable (accesslayerorg#298).

Closes accesslayerorg#302
Closes accesslayerorg#298
@Akpolo

Akpolo commented May 28, 2026

Copy link
Copy Markdown

Follow-up: wired the two helpers into the live code paths so they're actually exercised (the first commit only added them):

Verified: tsc --noEmit clean, helper unit tests pass (10/10), eslint/prettier clean.

@Chucks1093 Chucks1093 merged commit 9be7c40 into accesslayerorg:main May 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

3 participants