/** * Process Exit Handlers for Things Factory * * === SIGNAL HANDLER CONFLICTS ISSUE (2025-09-01) === * * PROBLEM: * - Multiple libraries (Apollo Server, Puppeteer) automatically register SIGINT/SIGTERM handlers * - This caused handler conflicts and prevented proper cleanup of headless Chrome processes * - Up to 6+ handlers were registered simultaneously, causing interference * * ROOT CAUSE: * - Apollo Server: Automatic graceful shutdown handlers * - Puppeteer: Browser cleanup on process exit handlers * - Our code: Custom cleanup handlers * - Result: Multiple handlers competing to exit process, causing premature termination before cleanup completed * * SOLUTION: * 1. Apollo Server: Added `stopOnTerminationSignals: false` in server.ts & server-dev.ts * 2. Puppeteer: Added `handleSIGINT: false, handleSIGTERM: false, handleSIGHUP: false` in browser-factory.ts * 3. Unified cleanup: Single handler in this file manages all cleanup (headless pools, pubsub, etc.) * 4. Simplified pool cleanup: Direct `drain() -> clear()` without complex fallbacks * * LESSON LEARNED: * - Always check for signal handler conflicts when multiple libraries are involved * - Keep cleanup logic simple - complex fallbacks often cause more problems * - Document these kinds of integration issues for future reference * * FILES MODIFIED: * - server.ts: stopOnTerminationSignals: false * - server-dev.ts: stopOnTerminationSignals: false * - browser-factory.ts: handleSIGINT/SIGTERM: false * - pool-manager.ts: simplified cleanup logic */ export declare function setupProcessExitHandlers(): void;