fix: Improve error handling in GenerationJobManager for allSubscribersLeft handlers

- Enhanced the error handling logic when retrieving content parts for allSubscribersLeft handlers, ensuring that any failures are logged appropriately.
- Updated the promise chain to catch errors from getContentParts, improving robustness and clarity in error reporting.
This commit is contained in:
Danny Avila 2025-12-15 09:35:19 -05:00
parent 829be5533f
commit 71a1a69568
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956

View file

@ -221,16 +221,24 @@ class GenerationJobManagerClass {
currentRuntime.syncSent = false; currentRuntime.syncSent = false;
// Call registered handlers (from job.emitter.on('allSubscribersLeft', ...)) // Call registered handlers (from job.emitter.on('allSubscribersLeft', ...))
if (currentRuntime.allSubscribersLeftHandlers) { if (currentRuntime.allSubscribersLeftHandlers) {
this.jobStore.getContentParts(streamId).then((content) => { this.jobStore
const parts = content ?? []; .getContentParts(streamId)
for (const handler of currentRuntime.allSubscribersLeftHandlers ?? []) { .then((content) => {
try { const parts = content ?? [];
handler(parts); for (const handler of currentRuntime.allSubscribersLeftHandlers ?? []) {
} catch (err) { try {
logger.error(`[GenerationJobManager] Error in allSubscribersLeft handler:`, err); handler(parts);
} catch (err) {
logger.error(`[GenerationJobManager] Error in allSubscribersLeft handler:`, err);
}
} }
} })
}); .catch((err) => {
logger.error(
`[GenerationJobManager] Failed to get content parts for allSubscribersLeft handlers:`,
err,
);
});
} }
} }
}); });