计划任务超时后会释放锁,但仍会继续运行任务,允许无限重叠执行
To Reproduce 1. Register a ScheduledTask whose execute() can legitimately take longer than DefaultSchedulerPlugin's defaultTimeout (60s) - no explicit timeout override on the task. 2. Have execute() do real, slow work - in the reproduction below, poll something for up to 15 minutes. 3. Let the task run past the 60s default timeout. 4. Observe the warn/error log pair (timed out after 60000ms/failed with error: Task timed out), the lock released, and - once the next cron tick fires - a second execution of the same task starting while the first is still running. Expected behavior Either the task's own execution is genuinely cancelled when it times out, or the lock is held until the underlying promise actually settles, so a timeout can never produce two concurrent executions of the same task. Actual behavior The lock is released immediately on timeout while the real execution continues detached. Nothing tracks or bounds how many of these detached executions can pile up. Real-world trigger Core's own SearchJobBufferService.runPendingSearchUpdates() (packages/core/src/plugin/default-search-plugin/search-job-buffer/search-job-buffer.service.ts) polls just-released apply-collection-filters jobs to completion with: await forkJoin(...subscribableCollectionJobs.map(sj => sj.updates({ pollInterval: 500, timeoutMs: 15 * 60 * 1000 }))) - i.e. up to 15 minutes. Any ScheduledTask that calls runPendingSearchUpdates() without setting its own timeout above 15 minutes is therefore guaranteed to hit DEFAULT_TIMEOUT (60s) on any run that takes longer than a minute, and is guaranteed to eventually overlap itself. Screenshots/Videos N/A - this is a background scheduled-task bug, not a UI issue. Error logs Scheduled task flush-search-index-buffer timed out after 60000ms Scheduled task "flush-search-index-buffer" failed with error: Task timed out
内容来源: vendurehq/vendure