Skip to content

Feature/per method timeout traceids injectable rpc#405

Open
valoryyaa-byte wants to merge 3 commits into
Stellar-split:mainfrom
valoryyaa-byte:feature/per-method-timeout-traceids-injectable-rpc
Open

Feature/per method timeout traceids injectable rpc#405
valoryyaa-byte wants to merge 3 commits into
Stellar-split:mainfrom
valoryyaa-byte:feature/per-method-timeout-traceids-injectable-rpc

Conversation

valoryyaa-byte and others added 3 commits June 29, 2026 12:36
Implements configurable per-method timeouts so read-heavy methods like
getLeaderboard can use longer timeouts than quick lookups, without
changing the global default.

- Add TimeoutConfig type and TimeoutManager class (src/timeout.ts)
- Add RequestTimeoutError with { method, timeoutMs } (src/errors.ts)
- Add withTimeout() helper using AbortController; each retry attempt
  gets a fresh timeout window
- Add timeout option to StellarSplitClientConfig
  (e.g. { default: 10000, getLeaderboard: 30000, getInvoiceHistory: 20000 })
- Per-call override: sdk.getLeaderboard({ timeout: 60000 })
- sdk.getTimeoutConfig() returns resolved timeout for every known method
- Add getLeaderboard() and getInvoiceHistory() methods to client
- Export TimeoutConfig, TimeoutManager, TimeoutError, RequestTimeoutError
- Unit tests: timer fires correctly, fast path succeeds, error shape

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Each SDK method call now generates a unique UUID v4 trace ID that
flows through telemetry hooks and RPC request headers, enabling
correlation of SDK calls with server-side logs.

- Add TraceIdManager class with setGenerator() for custom ID sources
  (e.g. OpenTelemetry span IDs) and globalTraceIdManager singleton
- Add traceId field to TelemetryCallStartParams, TelemetryCallEndParams,
  and TelemetryErrorContext; all telemetry hooks receive it
- Add X-Trace-Id header to outgoing RPC requests via interceptors
- Add traceId property to RPCRequest (src/interceptors.ts)
- _withTelemetry generates traceId per call and propagates it through
  all hook payloads; callers can supply their own via opts.traceId
- sdk.setDefaultTraceIdGenerator(fn) allows custom generation
- Per-call override: sdk.getInvoice(id, { traceId: 'my-trace-123' })
- Export TraceIdManager, globalTraceIdManager, TraceIdGenerator
- Unit tests: UUID format, uniqueness, custom generators, hook payloads

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…esting

Refactors the Soroban transport dependency into an injectable interface
so callers can swap in custom transports for testing or alternative
environments without monkey-patching.

- Add RpcClient interface (src/rpcClient.ts): simulateTransaction,
  sendTransaction, getTransaction, getEvents, getLatestLedger,
  getAccount, getFeeStats
- Add SorobanRpcAdapter wrapping SorobanRpc.Server (default, backward-compat)
- Add rpcClient option to StellarSplitClientConfig; when provided it
  takes priority over container.getRPCClient() and the default server
- server getter updated to return _injectedRpcClient first, enabling
  full transport substitution; connection-pool and retry logic wrap it
- Add MockRpcClient exported from @stellar-split/sdk/testing:
  - Configurable per-call queued responses and errors
  - Tracks calls.simulate / calls.send / calls.getTransaction / calls.getEvents
  - queueSimulateResponse(), queueSendResponse(), queueGetTransactionResponse()
  - setDefault*Response() overrides; reset() clears state
- Export RpcClient, SorobanRpcAdapter from package root
- Unit tests: interface coverage, queued responses, error propagation,
  client accepts injected RpcClient and routes calls through it

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@valoryyaa-byte 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant