Skip to content

fix(preview): TypeError null.addInstance in PreviewPanel handleOpenInSystem #1792

@kaizhou-lab

Description

@kaizhou-lab

Problem

Sentry Issue: ELECTRON-C6 (3 occurrences, last seen 2026-03-25)

TypeError: Cannot read properties of null (reading 'addInstance') thrown from handleOpenInSystem in PreviewPanel.tsx:384.

Root Cause

Arco Design's Message.useMessage() hook stores a ref to the context holder component. When handleOpenInSystem calls await ipcBridge.shell.openFile.invoke() and the IPC call rejects, the preview panel may have already unmounted, making contextHolderRef.current null. The subsequent messageApi.error() call then crashes with the TypeError.

Stack Trace

PreviewPanel.tsx:384 (handleOpenInSystem) → messageApi.error()
useMessage.js:66 → addNotice()
useMessage.js:53 → contextHolderRef.current.addInstance(notice) // null!

Fix

Wrap messageApi calls in handleOpenInSystem with try-catch to gracefully handle the unmounted context holder case.

Affected Versions

  • v1.9.0 (confirmed)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions