Skip to content

feat: detect and alert on stuck Soroban transactions - #1123

Open
VeronicDev wants to merge 4 commits into
Pulsefy:mainfrom
VeronicDev:feat/detect-stuck-soroban-transactions
Open

VeronicDev wants to merge 4 commits into
Pulsefy:mainfrom
VeronicDev:feat/detect-stuck-soroban-transactions

Conversation

@VeronicDev

Copy link
Copy Markdown

Summary

Closes #948 — Detect and Alert on Stuck Soroban Transactions

Adds stuck-transaction detection, per-operation-type metrics, and an admin endpoint for operators to surface transactions stuck in non-terminal state past a configurable ledger window.

Changes

Prisma Model

  • SorobanTransaction model with status, operationType, retryableErrorType, retryCount, and ledger sequence tracking

Lifecycle Service (soroban-transaction-lifecycle.service.ts)

  • trackTransaction() — registers a new on-chain transaction
  • updateTransactionState() — updates state; auto-classifies terminal vs retryable errors
  • detectStuckTransactions() — scheduled scan (every 30s) finding non-terminal txs exceeding maxLedgerAge (default 50 ledgers)
  • isRetryable() — public method distinguishing RetryableErrorType (NETWORK_TIMEOUT, RPC_ERROR, etc.) from terminal errors (NOT_AUTHORIZED, PACKAGE_EXPIRED, etc.)
  • Age estimation uses lastLedgerSequence when available, falls back to time-based estimation

Metrics

  • getStuckMetrics() — returns totalStuck, byOperationType, byRetryableErrorType, oldestStuckAge
  • Reset each scan cycle for fresh aggregation

Admin Endpoints

Endpoint Description
GET /api/v1/admin/soroban-transactions/stuck List stuck txs with ?operationType= and ?retryableOnly=true filters
GET /api/v1/admin/soroban-transactions/stuck/metrics Aggregated metrics breakdown
GET /api/v1/admin/soroban-transactions/config Current detection thresholds

Tests (31 passing)

  • Stuck detection with ledger age and time-based fallback
  • Retryable vs terminal error classification
  • Recovered transactions (CONFIRMED/FAILED no longer flagged)
  • Retryable errors keeping transactions stuck with incremented retryCount
  • Metrics aggregation by operation type and error type
  • Configuration and edge cases

Closes #948

Add stuck-transaction detection, per-operation-type metrics, and an admin
endpoint for operators to surface transactions stuck in non-terminal state.

- Stuck detection in lifecycle service with configurable maxAgeMs threshold
- Scheduled scan every 30s with in-memory metrics aggregation
- Metrics: totalStuck, byOperationType, byErrorType, oldestStuckAgeMs
- Admin REST: GET /admin/soroban-transactions/stuck, /stuck/metrics, /config
- 14 tests covering stuck, recovered, terminal, retryable, and metrics

Closes Pulsefy#948

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@VeronicDev 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

@Cedarich

Copy link
Copy Markdown
Contributor

Kindly fix CI

VeronicDev and others added 2 commits September 2, 2026 16:35
- Replace CronExpression.EVERY_30_SECONDS with string literal to fix unused import
- Remove unused txYoung variable in test
- Fix prettier formatting in controller and lifecycle service
- Remove unnecessary type assertion on errorType

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
The CronExpression import was left in the test file after switching to
string literal for the @Cron decorator. Also fix prettier formatting
in stuck-transaction.types.ts.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@VeronicDev

Copy link
Copy Markdown
Author

Kindly merge

CI Fixed

@Cedarich

Cedarich commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Kindly resolve conflict

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.

Detect and Alert on Stuck Soroban Transactions

2 participants