{"record":{"id":"7bc6360989d29997","repo":"vuejs/devtools-v6","slug":"on-getcomponentinstances-is-not-implemented-for-vu","errorCode":null,"errorMessage":"on.getComponentInstances is not implemented for Vue 2","messagePattern":"on\\.getComponentInstances is not implemented for Vue 2","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"packages/app-backend-vue2/src/index.ts","lineNumber":75,"sourceCode":"\n    api.on.editComponentState((payload) => {\n      editState(payload, api.stateEditor)\n    })\n\n    api.on.getComponentRootElements((payload) => {\n      payload.rootElements = getRootElementsFromComponentInstance(payload.componentInstance)\n    })\n\n    api.on.getComponentDevtoolsOptions((payload) => {\n      payload.options = payload.componentInstance.$options.devtools\n    })\n\n    api.on.getComponentRenderCode((payload) => {\n      payload.code = payload.componentInstance.$options.render.toString()\n    })\n\n    api.on.getComponentInstances(() => {\n      console.warn('on.getComponentInstances is not implemented for Vue 2')\n    })\n  },\n\n  setupApp(api, appRecord) {\n    const { Vue } = appRecord.options.meta\n    const app = appRecord.options.app\n\n    // State editor overrides\n    api.stateEditor.createDefaultSetCallback = (state) => {\n      return (obj, field, value) => {\n        if (state.remove || state.newKey) {\n          Vue.delete(obj, field)\n        }\n        if (!state.remove) {\n          Vue.set(obj, state.newKey || field, value)\n        }\n      }\n    }","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/vuejs/devtools-v6/blob/dd2ab5d4275187cbd81952a2a3d53c335643c1f4/packages/app-backend-vue2/src/index.ts#L57-L93","documentation":"The Vue 2 backend registers a handler for the `api.on.getComponentInstances` devtools event, but Vue 2's internals do not expose a supported way to retrieve all component instances for that API, so the handler only logs this warning. The devtools feature requesting instances gets no data. It is expected behavior on Vue 2 apps, not a bug.","triggerScenarios":"Any devtools frontend/extension feature calling getComponentInstances while connected to an app running the app-backend-vue2 backend (Vue 2.x app).","commonSituations":"Using devtools features designed for Vue 3 (component instance listing for custom panels, open-in-editor flows) against a Vue 2 app; plugin authors calling the API expecting Vue 3 parity.","solutions":["Accept the limitation: this API is Vue 3-only; access Vue 2 instances via appRecord options (`appRecord.options.app`) or the root instance's `$children` traversal instead.","Feature-detect: check the backend/major version before calling getComponentInstances and skip the call for Vue 2.","If you need instance lists in Vue 2 tooling, walk the component tree from the root instance yourself.","Migrate the app to Vue 3 if full devtools API parity is required."],"exampleFix":"// before\napi.on.getComponentInstances(cb) // warns on Vue 2\n\n// after\nif (appRecord.options.meta.Vue.version.startsWith('3')) {\n  api.on.getComponentInstances(cb)\n} else {\n  const root = appRecord.options.app\n  const walk = c => { cb([c]); c.$children.forEach(walk) }\n  walk(root)\n}","handlingStrategy":"type-guard","validationCode":"const isVue2 = appRecord.options.meta.Vue.version.startsWith('2')\nif (!isVue2) api.on.getComponentInstances(cb)","typeGuard":"function isVue3App(appRecord) { return appRecord.options.meta.Vue.version.startsWith('3') }","tryCatchPattern":null,"preventionTips":["Feature-check the Vue major version before using getComponentInstances","For Vue 2, traverse instances from the root via $children instead","Expect partial API parity on Vue 2 backends"],"tags":["vue2","api-limitation","unimplemented","devtools"],"backgroundTag":"api-not-implemented","analyzedSha":"dd2ab5d4275187cbd81952a2a3d53c335643c1f4","analyzedAt":"2026-08-31T12:41:59.822Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}