T09 · Insecure Skill Coding Practices
- Location
components/scheduler.js:15- Finding
Timed-Out Tasks Continue Running and May Be Retried Concurrently
- Content
View full analysis
setTimeout(resolve, backoffMs)); } // Check overall timeout if (Date.now() - startTime > this.timeoutMs) { throw new Error('Task execution timed out'); } } throw new Error(`Task failed after ${this.maxRetries} attempts`); } // Run task with configurable timeout async runWithTimeout(task, context) { return new Promise((resolve, reject) => { const taskPromise = typeof task === 'function' ? task(context) : Promise.resolve(task); const timeoutId = setTimeout(() => { reject(new Error('Task execution timed out')); }, this.timeoutMs); taskPromise .then((result) => { clearTimeout(timeoutId); resolve(result); }) .catch((error) => { clearTimeout(timeoutId); reject(error); }); }); } ``` ### Technical Analysis `runWithTimeout()` implements a timeout by rejecting an outer promise. Rejecting that promise does not cancel the underlying `taskPromise`. JavaScript promi ...[truncated 2421 chars]- Remediation
View remediation
