Skip to content

chore(docs): add a graceful shutdown section to the README - #159

Draft
schematic-orbit wants to merge 1 commit into
mainfrom
docs-graceful-shutdown
Draft

chore(docs): add a graceful shutdown section to the README#159
schematic-orbit wants to merge 1 commit into
mainfrom
docs-graceful-shutdown

Conversation

@schematic-orbit

@schematic-orbit schematic-orbit commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Documents graceful shutdown, prompted by a customer (#schematic-syrto) who hit
the real failure mode: a credit-lease redemption track is buffered
client-side, and if the process takes a SIGTERM before it flushes, the lease's
unspent remainder is refunded at release/expiry and the work goes unbilled.

close() already awaits the buffer flush (3 retries, exponential backoff), so
the fix on their side is one line — but the README never said so and showed
client.close() unawaited in all 17 snippets.

  • New ## Graceful shutdown H2 after Installation and Setup: SIGTERM/SIGINT
    handler, the flush semantics, the lease-redemption consequence of dropping
    events, and the in-memory vs shared-Redis lease-release difference already
    documented on close() in src/wrapper.ts.
  • Awaits close() in the Cloudflare Worker example, whose handler is already
    async. The other 16 calls are left alone — they sit at the top level of
    standalone snippets, so a blanket await would be wrong; the new section
    says as much explicitly.
  • One cross-reference from Credit Leases and Reservations.

nodejs.mdx in schematic-fern-config is generated from this README by
scripts/sync_sdk_readmes.py, so it picks this up on the next weekly sync
(Mon 11:00 UTC) or via workflow_dispatch — no fern-config edit needed.

Verified: all 30 ```ts blocks parse cleanly under the TypeScript parser, no
await introduced outside an async context (checked by AST walk, not grep),
code fences balanced, all in-page anchors resolve. Not verified: docs-site
rendering of the regenerated `nodejs.mdx` — that only exists after the sync runs.

Companion: SchematicHQ/schematic-fern-config#413 fixes the sync script so the
generated nodejs.mdx keeps its site-relative docs links instead of having them
clobbered on the next sync. Independent of this PR; either can land first.

close() is awaitable and flushes the event buffer, but the README never
said so and showed it unawaited everywhere. Adds a Graceful shutdown H2
with a SIGTERM/SIGINT handler, spells out the flush semantics (3 retries
with exponential backoff), calls out that dropped track events carrying
a leaseId leave work unbilled, and documents the in-memory vs shared
Redis lease-release difference. Also awaits close() in the Cloudflare
Worker example, whose handler is already async.
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.

1 participant