Skip to content

Graceful shutdown can forcibly kill in-flight Stellar payouts #78

Description

@cybermax4200

Why this matters now: Ties directly to #2 — a forced exit mid-payout is the realistic trigger for a double-spend.

Problem / What: app.ts:91-136 calls server.close then shuts down workers and process.exit(0) after a hard 10s setTimeout. A rewardWorker job submitting a Stellar transaction can be mid-flight when the 10s elapses; worker.close() only waits for currently active jobs up to its own timeout, and a slow Horizon submit can be killed after the tx is broadcast but before PAID is recorded → row left PROCESSING → reclaimed → double payout (#2).

Key Challenges: Making shutdown wait for in-flight payouts to reach a durable state (or coordinate with the idempotency fix in #2), and tuning the forced-exit timeout against worst-case Horizon latency.

Acceptance Criteria:

Relevant files/functions: src/app.ts:91-136, src/workers/rewardWorker.ts:162-176, src/services/rewardPayoutSweeper.ts:84-121.

Out of scope: Zero-downtime multi-instance deploy strategy.

Labels: advanced, reliability, security

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions