Skip to content

fix(mcp): TypeError on null addInstance when toggling MCP server after unmount #1774

@kaizhou-lab

Description

@kaizhou-lab

Description

useMcpServerCRUD uses a hook-based useMessage API from @arco-design/web-react to show toast notifications. When the parent component unmounts during an async MCP operation (toggle, delete, edit), the internal contextHolderRef.current becomes null, causing:

TypeError: Cannot read properties of null (reading 'addInstance')

Context

  • Sentry issue: ELECTRON-D (29 occurrences, last seen 2026-03-26)
  • Stack trace: useMcpServerCRUD.ts:233 → useMessage.js:53 → contextHolderRef.current.addInstance
  • The static Message API is lifecycle-independent and safe to call after unmount

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions