diff --git a/changelog.md b/changelog.md index 725d86c..2714a71 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## 2026-03-23 - 8.0.1 - fix(servicemanager) +cancel shutdown timeouts after services stop + +- Replace the shutdown race delay with a cancellable Timeout in ServiceManager. +- Prevent timeout handlers from lingering after a service stops successfully during shutdown. + ## 2026-03-20 - 8.0.0 - BREAKING CHANGE(service) expand service lifecycle management with instance-aware hooks, startup timeouts, labels, readiness waits, and auto-restart support diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 8ad1039..266baf5 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/taskbuffer', - version: '8.0.0', + version: '8.0.1', description: 'A flexible task management library supporting TypeScript, allowing for task buffering, scheduling, and execution with dependency management.' } diff --git a/ts/taskbuffer.classes.servicemanager.ts b/ts/taskbuffer.classes.servicemanager.ts index fe4b92e..04ed5ed 100644 --- a/ts/taskbuffer.classes.servicemanager.ts +++ b/ts/taskbuffer.classes.servicemanager.ts @@ -158,12 +158,15 @@ export class ServiceManager { runningInLevel.map(async (name) => { const service = this.services.get(name)!; try { - await Promise.race([ - service.stop(), - plugins.smartdelay.delayFor(this.options.shutdownTimeoutMs).then(() => { - throw new Error(`Timeout stopping service '${name}'`); - }), - ]); + const timeout = new plugins.smartdelay.Timeout(this.options.shutdownTimeoutMs); + const timeoutPromise = timeout.promise.then(() => { + throw new Error(`Timeout stopping service '${name}'`); + }); + try { + await Promise.race([service.stop(), timeoutPromise]); + } finally { + timeout.cancel(); + } } catch (err) { logger.log('warn', `${this.name}: error stopping '${name}': ${err instanceof Error ? err.message : String(err)}`); } diff --git a/ts_web/00_commitinfo_data.ts b/ts_web/00_commitinfo_data.ts index 8ad1039..266baf5 100644 --- a/ts_web/00_commitinfo_data.ts +++ b/ts_web/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/taskbuffer', - version: '8.0.0', + version: '8.0.1', description: 'A flexible task management library supporting TypeScript, allowing for task buffering, scheduling, and execution with dependency management.' }