From aac34321b664cfb79e125b07a95648f01f2fc22f Mon Sep 17 00:00:00 2001 From: Akuria <46207353+Akur1a@users.noreply.github.com> Date: Mon, 11 May 2026 23:18:42 +0800 Subject: [PATCH] fix: guard openInEditor when inspector is unavailable When the component inspector is not initialized, calling openInEditor through the Vite plugin path throws because __VUE_INSPECTOR__ is missing. Guard the call and log a clear warning instead, so DevTools does not crash in this state. Refs #824 --- packages/devtools-kit/src/core/open-in-editor/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/devtools-kit/src/core/open-in-editor/index.ts b/packages/devtools-kit/src/core/open-in-editor/index.ts index 65ca37852..09199b602 100644 --- a/packages/devtools-kit/src/core/open-in-editor/index.ts +++ b/packages/devtools-kit/src/core/open-in-editor/index.ts @@ -29,7 +29,12 @@ export function openInEditor(options: OpenInEditorOptions = {}) { } else if (devtoolsState.vitePluginDetected) { const _baseUrl = target.__VUE_DEVTOOLS_OPEN_IN_EDITOR_BASE_URL__ ?? baseUrl - target.__VUE_INSPECTOR__.openInEditor(_baseUrl, file, line, column) + if (target.__VUE_INSPECTOR__) { + target.__VUE_INSPECTOR__.openInEditor(_baseUrl, file, line, column) + } + else { + console.warn('[Vue DevTools] Component inspector is not available. If you have disabled the Options API, the component inspector may not be initialized.') + } } } }