Repair Double Completion Races

    by Mariusz Wrzeszczynski

    1

    Repair double completion, duplicate callbacks, timeout/cancel races, stale retry callbacks, duplicate response writes, and cleanup running twice.

    Secure checkout via Stripe

    0 installsSecurity scanned

    Works with the AI tools you already use

    CClaude CodeCCursorCCodex CLIGGitHub CopilotGGemini CLI+17 more

    See it in action

    You say

    Our Node/TypeScript payment-status wrapper converts a callback SDK into a Promise. We start a timeout timer, register an AbortSignal listener, and call the SDK. If the timeout fires first we reject and release a semaphore permit, but the SDK callback can arrive later and release the permit again. In one path the callback also invokes an onComplete hook after the timeout. Repair locally with fake clocks and deterministic callback barriers. Do not call production, change payment semantics, or assume a timeout means the partner did not process the request.

    Your agent does

    Double-completion race found. Timeout, abort, and SDK callback can all settle one operation and release the same semaphore. The repair centralizes terminal ownership, makes cleanup exactly-once locally, fences late callbacks, and preserves unknown external outcome after timeout.

    What you get

    Prevent 'headers already sent' errors in HTTP response handlers.Stop late retry attempts from completing newer operations via generation fencing.Ensure resource cleanup runs exactly once during socket close races.Convert flaky async tests into deterministic race condition validations.

    About this skill

    Async operations often have several ways to finish: callback, timeout, cancellation, socket close, retry completion, or response commit. Without one terminal owner, two paths can settle the same promise/future, invoke user callbacks twice, release resources twice, or let an old retry attempt complete newer work.

    Repair Double Completion Races maps every completion source, introduces a single terminal state transition and generation fencing, makes late completions observable and side-effect-free, and proves the repair with deterministic fake-clock/barrier tests.

    It does not alter business retry semantics or pretend timeout/cancellation proves an external operation did not happen.

    How to install

    Drop the file into your AI Agent. Works with Claude, Cursor, ChatGPT, and 20+ more.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill passes our trust checks below.

    Security scanned

    Passed our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    30-day refund

    Not a fit? Get your money back

    Trust & safety

    Security scanned

    Verified clean today

    Listedtoday

    Frequently Asked Questions

    Popular in AI Agents & LLM Ops