Skip to content

fix(electron): 初始化进度回调向已销毁的 WebContents 发送事件,Runtime bootstrap 期间关窗主进程抛 Object has been destroyed #665

Closed

Description

@qiyinxi

由 Sentry 每日分诊自动建立。Sentry issue: AUTO-MAS-DESKTOP-16
https://auto-mas.sentry.io/issues/AUTO-MAS-DESKTOP-16

现象

TypeError: Object has been destroyed,3 条事件(同一秒),v5.5.0-beta.4,Electron 37.10.3,level: fatal、handled: no,CN 南宁。应用 06:07:43 启动,06:07:49 崩溃——Runtime bootstrap 还在推进度时渲染进程已经没了。

定位

堆栈(beta.4 编译产物):RuntimeSession.consumeStdout → runtimeInitializationService.onProgress → BootstrapProgressBridge.emit → initializationHandlers.js:316 → webContents.send。

dev 上对应 frontend/electron/ipc/initializationHandlers.ts 里传给 initService.initialize(...) / retryStageViaRuntime(...) 的进度回调,写法都是 event.sender.send('initialization-progress', progress)。该文件共 13 处 event.sender.send(...),git grep -n isDestroyed -- frontend/electron/ipc/initializationHandlers.ts 在 dev 上零命中(main.ts 里有 12 处守卫)。

根因

进度回调与后端状态回调都活得比一次 IPC 调用长:窗口关闭、应用退出后 Runtime 子进程还在往 stdout 吐进度,回调拿着已销毁的 WebContents 去 send,直接成为主进程未捕获异常。与 #652 同一家族,#652 是后端退出时的状态回调,这条是 bootstrap 进度回调,触发路径不同、缺的是同一个 isDestroyed() 守卫。

复现与影响

初始化进行中关闭窗口即可触发(未在本机复现,判断基于堆栈与源码)。影响:退出时主进程以 fatal 收场,走不到正常的清理路径。

Activity

  1. Taimer0721 commented on Sep 17, 2026

    @Taimer0721
    Contributor

    由 Claude Code 定时任务 Sentry daily triage 自动生成(模型:Opus 5 (1M context)),未经人工复核,仅供参考。

    同一条失败路径在 beta.6 上出现了新的 Sentry 分组:AUTO-MAS-DESKTOP-17 — https://auto-mas.sentry.io/issues/AUTO-MAS-DESKTOP-17

    • 1 次,release v5.5.0-beta.6,2026-09-17 04:18 UTC,Windows 10 / Electron 37.10.3,应用启动后 4 秒内。
    • 堆栈:initializationHandlers.js:318 的 event.sender.send(...) ← BootstrapProgressBridge.emit ← runtimeInitializationService.onState ← RuntimeSession.dispatch/consumeStdout,TypeError: Object has been destroyed,level fatal、unhandled。
    • 与本 issue 是同一处(Runtime bootstrap 进度回调向已销毁的 WebContents 发消息),只是分组不同;fix(electron): 初始化进度与后端状态回调在渲染进程销毁后不再向 WebContents 发送事件 #669 的守卫覆盖这条。
  2. added a commit that references this issue on Sep 24, 2026
  3. qiyinxi commented on Sep 27, 2026

    @qiyinxi
    MemberAuthor

    已随 v5.6.0 修复:#669 把 initializationHandlers.ts 里所有 event.sender.send(含初始化进度回调)换成先判 isDestroyed() 的 sendToSender。按 #989 的分诊口径关闭;v5.6.0 上 Sentry 再出现请直接回复。


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Sentry dailySentry daily issuesbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions