Skip to content

Conversation

@jsantell
Copy link
Collaborator

@jsantell jsantell commented Oct 22, 2025

Occurs when running bg worker in prod. TBD on what is actually terminating the server to cause this

   at �[0m�[1m�[3mshutdown�[0m (�[0m�[36mfile:///tmp/deno-compile-bg-charm-service/packages/background-charm-service/src/main.ts�[0m:�[0m�[33m44�[0m:�[0m�[33m15�[0m)
   service.stop().then(() => {
�[0m�[1m�[31merror�[0m: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'then')

Summary by cubic

Fixes a crash during shutdown when the background service isn’t running by making stop() always return a Promise and by binding signal handlers to a service-aware shutdown function. Prevents the TypeError and ensures graceful exits in production.

  • Bug Fixes
    • stop() now returns a Promise in all cases (returns Promise.resolve([]) when not running), avoiding .then on undefined.
    • Reworked shutdown to capture the service (shutdown(service)) for SIGINT/SIGTERM, removing the ts-ignore and ensuring consistent behavior.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@jsantell jsantell merged commit a91400c into main Oct 22, 2025
9 checks passed
@jsantell jsantell deleted the bg-worker-graceful-shutdown branch October 22, 2025 21:33
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.

2 participants