Skip to content

fix(agents): prevent unhandled promise rejection in bootstrap initialization#1933

Merged
piorpua merged 1 commit intomainfrom
fix/sentry-ELECTRON-E0
Mar 30, 2026
Merged

fix(agents): prevent unhandled promise rejection in bootstrap initialization#1933
piorpua merged 1 commit intomainfrom
fix/sentry-ELECTRON-E0

Conversation

@kaizhou-lab
Copy link
Copy Markdown
Collaborator

Summary

  • Add .catch(() => {}) to bootstrap promises in OpenClawAgentManager, NanoBotAgentManager, and RemoteAgentManager to prevent Node.js unhandledRejection events when agent initialization fails (e.g. gateway binary not found on PATH)
  • The error still propagates correctly when sendMessage() awaits this.bootstrap, so callers get proper error handling
  • Follows the same pattern already used in GeminiAgentManager (line 138)

Sentry issue: ELECTRON-E0 — 6 occurrences, last seen 4 hours ago. Error: Failed to start OpenClaw Gateway: Gateway exited with code 1 causing unhandledPromiseRejection on Windows when openclaw binary is not in PATH.

Test plan

  • New unit tests in OpenClawAgentManagerBootstrap.test.ts verify:
    • Successful bootstrap works as before
    • Failed bootstrap does NOT trigger unhandled rejection
    • Failed bootstrap error propagates correctly to sendMessage()
  • Existing RemoteAgentManager.test.ts still passes (23/23)
  • bunx tsc --noEmit passes
  • bun run lint — 0 errors

…ization

Add .catch() to bootstrap promises in OpenClawAgentManager,
NanoBotAgentManager, and RemoteAgentManager to prevent unhandled
rejection when agent initialization fails (e.g. gateway binary not
found). The error still propagates when sendMessage() awaits bootstrap.

Follows the same pattern already used in GeminiAgentManager.

Fixes ELECTRON-E0
@kaizhou-lab kaizhou-lab marked this pull request as ready for review March 30, 2026 09:19
@piorpua piorpua added the bot:reviewing Review in progress (mutex) label Mar 30, 2026
@piorpua
Copy link
Copy Markdown
Contributor

piorpua commented Mar 30, 2026

Code Review #1933

变更概述

在 OpenClawAgentManager、NanoBotAgentManager、RemoteAgentManager 三个构造函数中各追加了 this.bootstrap.catch(() => {}) 一行,防止 agent 初始化失败时产生 unhandledRejection 事件(Sentry ELECTRON-E0)。同时新增 OpenClawAgentManagerBootstrap.test.ts 验证该行为。


方案评估

结论:方案合理

这是 Node.js 处理存储型 Promise unhandledRejection 的标准做法:通过 .catch(() => {}) 挂起 rejection 观察者,使引擎不将其视为未处理,同时错误仍可通过 await this.bootstrap 正常传播。该 pattern 与 GeminiAgentManager:138 完全一致,本 PR 只是补齐了另外三个 manager。


问题清单

无阻塞性问题。

结论

批准合并 — 修复精准,与项目已有模式完全一致,测试覆盖充分,无阻塞性问题。

本报告由本地 pr-review skill 生成,包含完整项目上下文,无截断限制。

@piorpua
Copy link
Copy Markdown
Contributor

piorpua commented Mar 30, 2026

✅ 已自动 review,无阻塞性问题,正在触发自动合并。

@piorpua piorpua merged commit 09f6571 into main Mar 30, 2026
17 checks passed
@piorpua piorpua deleted the fix/sentry-ELECTRON-E0 branch March 30, 2026 11:06
@piorpua piorpua added bot:done Auto-merged by bot and removed bot:reviewing Review in progress (mutex) labels Mar 30, 2026
wuhao1477 added a commit to wuhao1477/AionUi that referenced this pull request Mar 30, 2026
* 'main' of github.com:wuhao1477/AionUi: (40 commits)
  fix(agents): prevent unhandled promise rejection in bootstrap initialization (iOfficeAI#1933)
  fix(gemini): restore context after stopping a reply (iOfficeAI#1932)
  fix(codex): reject start promise immediately on process exit during startup (iOfficeAI#1929)
  fix(conversation): sync renamed titles with detail view (iOfficeAI#1927)
  fix(paste): deduplicate filenames when pasting multiple images simultaneously
  fix(mobile): add SafeArea support and update app icon (iOfficeAI#1926)
  fix(database): guard against undefined params in databaseBridge providers (iOfficeAI#1924)
  fix(conversation): validate type field before creating conversation (iOfficeAI#1921)
  fix(docs): restore wechat_group_5.png reference to wx-5.png in readme
  fix(snapshot): add maxBuffer to git add/commit exec calls (iOfficeAI#1914)
  refactor(acp): consolidate AGENT_SKILLS_DIRS into ACP_BACKENDS_ALL (iOfficeAI#1913)
  fix(gemini): guard against EACCES in workspace realpath during init (ELECTRON-BM) (iOfficeAI#1912)
  fix(channels): send raw QR ticket instead of page URL in WeChat WebUI login SSE (iOfficeAI#1910)
  .md format
  chore(pr-automation): fix missed sleep 5 in comment to sleep 10
  chore(pr-automation): increase auto-merge retry delay to 10s
  chore(pr-automation): add 5s retry for transient GitHub mergeStateStatus UNKNOWN
  fix(docs): remove trailing whitespace in OfficeCLI readmes
  chore(pr-automation): verify auto-merge success before labeling bot:done
  fix(snapshot): guard against non-existent workspace in WorkspaceSnapshotService.init (iOfficeAI#1906)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:done Auto-merged by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants