Skip to content

Await provider readiness and drain application lifecycles - #1

Draft
elucidsoft wants to merge 4 commits into
mainfrom
fix/lifecycle-drain
Draft

elucidsoft wants to merge 4 commits into
mainfrom
fix/lifecycle-drain

Conversation

@elucidsoft

@elucidsoft elucidsoft commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Application shutdown previously returned early to concurrent callers, hid provider failures and deadlines, and could leave partially started resources running after failed startup. Shutdown now waits for HTTP before stopping event, workflow and WebSocket providers, shares its outcome, rejects failure, and removes owned process listeners. Successful restart remains supported.

Bootstrap prepares event consumers but activates their subscriptions only after startup hooks and workflow-provider readiness. The BullMQ workflow provider waits for its producer and every step/parent worker; failed event-worker registration closes the candidate. WebSocket clients retire old sockets before manual reconnect so delayed callbacks cannot clear a replacement connection or lose its room rejoin.

Requires Bun 1.4.2 for the verified server-drain behaviour. Existing local CORS and consumer-injection fixes are preserved in a separate prerequisite commit. Shutdown hooks remain best-effort; a timeout does not cancel unfinished work, and consumer dependencies must stay open until provider drain succeeds.

Validation: the final full framework run passes 3,157 tests; TypeScript passes; lint exits successfully with warnings. The linked ActLume consumer passes 103 backend tests and both browser tests, including coordinator startup and SIGTERM. Earlier full runs had intermittent Redis connection-closed and cache stale-timeout failures; the cache case passed in isolation and the final full suite passed. Those intermittent failures remain unresolved. Automated review tooling was unavailable in these standalone checkouts.

@elucidsoft elucidsoft changed the title Drain application shutdown and isolate WebSocket reconnects Await provider readiness and drain application lifecycles Sep 6, 2026
Make provider startup await ready Redis connections, disable offline buffering, and expose bounded subscription acknowledgement for consumers that must reconcile after subscribing. Reject waiters on failure or shutdown.

Validation: full TypeScript check and 3157 tests passed, including 95 websocket-redis tests and real cross-instance subscription delivery.
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