/** * 停止卡住的任务430901CD */ import { Redis } from '@upstash/redis'; const redis = new Redis({ url: 'https://oriented-skink-40337.upstash.io', token: 'AZ2RAAIncDEyMzkzNTVmNWVhOTc0NWNmOWZiYTlmNGYyOTRmNGMzM3AxNDAzMzc', }); const taskId = '430901cd-b94f-4340-b46b-cbc11eff59c8'; async function stopTask() { // 获取现有状态 const existing = await redis.hget('slow_task:results', taskId); if (!existing) { console.log('任务不存在'); return; } const state = typeof existing === 'string' ? JSON.parse(existing) : existing; // 更新为失败 const failedState = { ...state, status: 'failed', errorMessage: '手动停止:任务卡住超过10分钟', updatedAt: Date.now(), canRetryFree: true, }; await redis.hset('slow_task:results', { [taskId]: JSON.stringify(failedState) }); console.log('✅ 任务已停止'); } stopTask().catch(console.error);