Skip to content

Add SDK graceful shutdown #118

@Kingsman-99

Description

@Kingsman-99

Label: complexity: high
Points: 200

Description

Abruptly terminating a process with an active SDK instance can lose queued operations and corrupt cache state. This issue adds shutdown() that flushes pending operations, persists cache to disk, closes all connections, and resolves when cleanup is complete.

Technical Context

Involves src/client.ts. shutdown(): Promise<void> drains the operation queue, calls cache.persist() if persistence is configured, removes all event listeners, and nullifies internal references. Register process.on('SIGTERM', () => client.shutdown()) automatically when in Node.js environment.

Acceptance Criteria

  • shutdown(): Promise<void> exported on StellarSplitClient
  • Pending queued operations flushed before shutdown completes
  • Cache persisted to disk when persistence configured
  • All event listeners removed on shutdown
  • Test verifies queued operation completes before shutdown resolves
  • All existing tests pass
  • TypeScript strict mode — zero any types

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions