fix(preview): guard messageApi calls against unmounted context holder#1793
Merged
fix(preview): guard messageApi calls against unmounted context holder#1793
Conversation
…mounted context holder Arco Design's Message.useMessage() throws TypeError when contextHolderRef.current is null (component unmounted after async IPC call). Wrap messageApi calls in try-catch to prevent unhandled rejection. Fixes ELECTRON-C6
Contributor
Code Review:fix(preview): guard messageApi calls against unmounted context holder (#1793)变更概述本 PR 修复了 Sentry issue ELECTRON-C6:在 方案评估结论:✅ 方案合理 针对 React 组件卸载后异步回调调用 UI API 的经典场景,try-catch 防御是标准且可靠的做法——相比 问题清单未发现新引入的问题。 Lint 工具报告的 汇总
结论✅ 批准合并 — 修复准确,代码简洁,测试覆盖了核心防御场景,无阻塞性问题。 本报告由本地 CONCLUSION: APPROVED |
Contributor
|
✅ 已自动 review,无阻塞性问题,正在触发自动合并。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1792
Summary
messageApi.error()andmessageApi.success()calls inhandleOpenInSystemwith try-catch to preventTypeError: Cannot read properties of null (reading 'addInstance')when the Arco Design Message context holder has been unmounted after an async IPC operationSentry Issue
ELECTRON-C6 — 3 occurrences, last seen 2026-03-25, affecting v1.9.0
Root cause: After
await ipcBridge.shell.openFile.invoke()rejects, the PreviewPanel may have unmounted, leavingcontextHolderRef.currentas null inside Arco'suseMessagehook.Verification
bun run test)bunx tsc --noEmit)bun run lint:fix)bun run format)