Skip to content

fix(processing): add per-step timeout enforcement to gracefulshutdown - #492

Open
beulah7717108-eng wants to merge 2 commits into
XStreamRollz:mainfrom
beulah7717108-eng:beulah/344-soft-delete-users
Open

fix(processing): add per-step timeout enforcement to gracefulshutdown#492
beulah7717108-eng wants to merge 2 commits into
XStreamRollz:mainfrom
beulah7717108-eng:beulah/344-soft-delete-users

Conversation

@beulah7717108-eng

Copy link
Copy Markdown

Summary

Adds per-step timeout enforcement to GracefulShutdown so no single hanging hook can block the entire shutdown sequence. Each registered shutdown hook now accepts an optional timeoutMs override. If a step exceeds its timeout, a warning is logged and shutdown continues to the next step. drainAll() in SessionRegistry also respects a per-session drain timeout via the SESSION_DRAIN_TIMEOUT_MS env var.

Also adds SHUTDOWN_TIMEOUT_MS and SESSION_DRAIN_TIMEOUT_MS to the config Zod schema so these values are validated at startup rather than read raw from process.env.

Related issues

Closes #342

Type of change

  • fix

Testing performed

cd xstreamroll-processing
npx tsc --noEmit                          # 0 errors
npx jest --testPathPattern='(lifecycle.shutdown|session-registry|lifecycle)\.test\.ts' --no-coverage
                                          # 32 passed, 0 failures

Tests added:

  • lifecycle.shutdown.test.ts: 4 new tests covering per-step timeout (hook exceeds timeout, per-step override, fallback to global timeout, multiple timed-out hooks)
  • session-registry.test.ts: 1 new test for drainAll() with timeout when a session's stop() hangs forever

Checklist — author

  • I rebased onto origin/main and resolved conflicts.
  • I ran the quality gates locally: npm run lint, npm run build, npm test.
  • Title follows Conventional Commits and references the issue (see above).
  • I added/updated tests where applicable and they pass locally.
  • No new TypeScript errors or lint warnings introduced.
  • Screenshots included for UI changes.

… - graceful shutdown timeout, soft-delete users, observability
Each shutdown hook accepts an optional timeoutMs override.

Timed-out steps log a warning and shutdown continues to the next step.

drainAll() in SessionRegistry respects a per-session drain timeout.

Added SHUTDOWN_TIMEOUT_MS and SESSION_DRAIN_TIMEOUT_MS to config.ts.

Closes XStreamRollz#342
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.

processing: lifecycle.ts GracefulShutdown has no timeout enforcement per step

1 participant