feat(publish): cancel stale queued publish tasks after queue timeout

Add CancelStaleQueuedPublishTasks to abort publish tasks that sit in the
queue past a configurable timeout (default 3 days) without being claimed by
a desktop client, so they no longer linger indefinitely as 'queued'. The
lease recovery worker runs the cleanup each cycle and reports a
cancelled_queued count; the timeout is configurable via job run config.
Aborted tasks carry a publish_queue_timeout error payload with a readable
Chinese duration, and the admin-web publish summary surfaces it as an
auto-cancelled queue-timeout message.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-08 22:56:37 +08:00
parent f1334aac80
commit 832d7f507d
5 changed files with 358 additions and 19 deletions
@@ -118,6 +118,7 @@ function inlineErrorPreview(messageText: string): string {
function summaryForRecord(record: PublishRecord, status: string): string {
const targetLabel = record.target_type === 'enterprise_site' ? '企业站点' : '目标平台'
const errorMessage = normalizeRecordErrorMessage(record.error_message, record.platform_id)
switch (status) {
case 'queued':
return record.target_type === 'enterprise_site'
@@ -134,6 +135,9 @@ function summaryForRecord(record: PublishRecord, status: string): string {
? '本次企业站发布失败,请检查站点连接或发布错误。'
: '本次发送失败,请检查账号状态或平台提示后重新提交。'
case 'cancelled':
if (errorMessage && /等待通道|publish_queue_timeout/.test(errorMessage)) {
return '等待通道超时,系统已自动取消。'
}
return '本次发布已取消。'
case 'unknown':
default: