Make pause state durable and survive process restarts#240
Merged
mikewheeleer merged 1 commit intoJun 29, 2026
Conversation
Persists the service pause flag to a small JSON state file so the paused state survives process restarts. An operator who pauses the service before a deploy will find it still paused afterward. - Add src/pauseState.ts with loadPausedState/savePausedState helpers - Update stores.ts to restore pause state at startup (skipped in test env for isolation) and persist it on every setPaused call - Emit admin.paused / admin.unpaused events via recordEvent for audit log - Add comprehensive tests in src/__tests__/durablePause.test.ts covering persistence, simulated restart, audit events, and status/health/metrics - Fix pre-existing TS compile errors (duplicate consts, missing exports, undefined references) that prevented the test suite from running at all Fixes StableRoute-Org#29 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
lgtm — merging this 🙌 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #29
Summary
src/pauseState.tswithloadPausedState/savePausedStatehelpers that persist the pause flag to a small JSON file (path configurable viaPAUSE_STATE_FILEenv var)stores.tssosetPaused()persists state on every call and the flag is restored from disk at module load (skipped inNODE_ENV=testfor test isolation)admin.paused/admin.unpausedaudit events viarecordEventon every pause/unpause actionsrc/__tests__/durablePause.test.tswith 18 tests covering persistence helpers, simulated restart, audit events, and reflection in/api/v1/admin/status, deep health, and metricsBULK_ABSOLUTE_MAX, missingevictRateBuckets,HEALTH_PROBE_KEY,trimEventLog,effectiveEventLogCap,WEBHOOK_MAX_EVENTS, etc.) that prevented the test suite from runningChanges
Implements the feature as described in the issue, following existing code patterns. Pause state is stored in
.pause_state.json(overridable viaPAUSE_STATE_FILE). I/O errors are logged but never propagated — the in-process state always takes effect even if the filesystem is unavailable. The recovery path (POST /api/v1/admin/unpause) remains always reachable regardless of pause state.