Skip to content

Commit 4b71fc3

Browse files
PBnicadclaude
andcommitted
fix: 添加容器 alarm 事件处理器防止异常
- 在 AgentContainer 类中添加 alarm() 方法 - 处理容器休眠定时器触发时的事件 - 防止未捕获异常导致错误日志 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 9da237b commit 4b71fc3

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

.claude/settings.local.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(docker build:*)",
5+
"Bash(npm install:*)",
6+
"Bash(npm run deploy:*)",
7+
"Bash(docker info:*)",
8+
"Bash(wrangler whoami:*)",
9+
"Bash(if [ -d \"d:/work/code_1/cloud-code/.github/workflows\" ])",
10+
"Bash(then ls \"d:/work/code_1/cloud-code/.github/workflows\")",
11+
"Bash(else echo \"Directory does not exist\")",
12+
"Bash(fi)",
13+
"Bash(git add:*)",
14+
"Bash(git commit -m \"$\\(cat <<''EOF''\nfeat: 添加 GitHub Actions 自动部署到 Cloudflare Workers\n\n- 添加 GitHub Actions workflow 配置\n- 更新 wrangler 到最新版本 4.60.0\n- 支持推送代码时自动部署和手动触发部署\n\nCo-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>\nEOF\n\\)\")",
15+
"Bash(git push:*)",
16+
"Bash(npx wrangler:*)",
17+
"Bash(npx tsc:*)",
18+
"Bash(git commit -m \"$\\(cat <<''EOF''\nfix: 添加容器 alarm 事件处理器防止异常\n\n- 在 AgentContainer 类中添加 alarm\\(\\) 方法\n- 处理容器休眠定时器触发时的事件\n- 防止未捕获异常导致错误日志\n\nCo-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>\nEOF\n\\)\")"
19+
]
20+
}
21+
}

src/container.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ export class AgentContainer extends Container {
4848
// 不 await,让 SSE 监听在后台运行,避免阻塞 blockConcurrencyWhile
4949
this._watchPromise = this.watchContainer()
5050
}
51+
52+
override async alarm(): Promise<void> {
53+
// 处理定时器事件,用于容器休眠/唤醒
54+
console.log('Container alarm triggered')
55+
// 基类 Container 会处理实际的休眠逻辑
56+
}
5157
}
5258

5359
const SINGLETON_CONTAINER_ID = 'cf-singleton-container'

0 commit comments

Comments
 (0)