From 820811cca213d5f57c6984a94a71fca0964dcbfd Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Mon, 23 Mar 2026 14:59:59 +0000 Subject: [PATCH] fix(servicemanager): cancel startup timeout once service initialization completes --- changelog.md | 6 ++++++ ts/00_commitinfo_data.ts | 2 +- ts/taskbuffer.classes.servicemanager.ts | 15 +++++++++------ ts_web/00_commitinfo_data.ts | 2 +- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/changelog.md b/changelog.md index 2714a71..e11fa19 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## 2026-03-23 - 8.0.2 - fix(servicemanager) +cancel startup timeout once service initialization completes + +- Replaces the startup timeout race delay with a cancellable Timeout instance +- Prevents the global startup timeout from lingering after startup finishes or fails + ## 2026-03-23 - 8.0.1 - fix(servicemanager) cancel shutdown timeouts after services stop diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 266baf5..1603faa 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.1', + version: '8.0.2', 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 04ed5ed..43c6037 100644 --- a/ts/taskbuffer.classes.servicemanager.ts +++ b/ts/taskbuffer.classes.servicemanager.ts @@ -82,12 +82,15 @@ export class ServiceManager { // Enforce global startup timeout if (this.options.startupTimeoutMs) { - await Promise.race([ - startupPromise, - plugins.smartdelay.delayFor(this.options.startupTimeoutMs).then(() => { - throw new Error(`${this.name}: global startup timeout exceeded (${this.options.startupTimeoutMs}ms)`); - }), - ]); + const timeout = new plugins.smartdelay.Timeout(this.options.startupTimeoutMs); + const timeoutPromise = timeout.promise.then(() => { + throw new Error(`${this.name}: global startup timeout exceeded (${this.options.startupTimeoutMs}ms)`); + }); + try { + await Promise.race([startupPromise, timeoutPromise]); + } finally { + timeout.cancel(); + } } else { await startupPromise; } diff --git a/ts_web/00_commitinfo_data.ts b/ts_web/00_commitinfo_data.ts index 266baf5..1603faa 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.1', + version: '8.0.2', description: 'A flexible task management library supporting TypeScript, allowing for task buffering, scheduling, and execution with dependency management.' }