Refactor hooks and worker service for improved session management and logging
- Updated new-hook.js, save-hook.js, and summary-hook.js to enhance logging and session handling. - Simplified session auto-creation logic in worker-service.ts to prioritize observation data preservation. - Added a blocking wait in ensureWorkerRunning function to prevent race conditions during worker startup. - Improved error handling and logging consistency across hooks.
This commit is contained in:
@@ -35,6 +35,14 @@ export function ensureWorkerRunning(): void {
|
||||
cwd: packageRoot,
|
||||
stdio: 'ignore'
|
||||
});
|
||||
|
||||
// Give PM2 200ms to actually start the worker
|
||||
// Prevents race condition where hooks fire before worker is ready
|
||||
// Simple blocking wait - no complex health checks needed
|
||||
const start = Date.now();
|
||||
while (Date.now() - start < 200) {
|
||||
// Busy wait
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user