Skip to content

perf(useComponentProps): treats Vue's internal __v_* flag reads as prop lookups (regex + theme lookups on every probe) #7185

Closed

Description

@tilalx

Environment

  • Operating System: Linux 7.2.9-200.fc44.x86_64
  • Node Version: v22.23.1
  • Nuxt Version: 4.6.0
  • CLI Version: 4.0.0
  • Nitro Version: 2.13.4
  • Package Manager: yarn@4.18.0
  • Builder: vite@8.3.3
  • User Config: app, colorMode, compatibilityDate, css, devtools, experimental, future, i18n, icon, imports, modules, nitro, postcss, routeRules, runtimeConfig, ssr, ui, vite
  • Runtime Modules: @nuxt/ui@4.11.3, @nuxtjs/i18n@10.6.0
  • Build Modules: -

Is this bug related to Nuxt or Vue?

Nuxt

Package

v4.x

Version

v4.11.3

Reproduction

This is a performance issue that only shows up in a CPU profile, so there is no playground link. It does not change any visible behaviour. The snippet below shows it directly: reading an internal Vue flag on the props proxy runs the regex case conversions.

import { defineComponent, h, isReadonly } from 'vue'
import { mount } from '@vue/test-utils'
import { useComponentProps } from '@nuxt/ui/runtime/composables/useComponentProps'

mount(defineComponent({
  props: { color: String },
  setup(raw) {
    const props = useComponentProps('button', raw)
    const replace = vi.spyOn(String.prototype, 'replace')
    isReadonly(props) // Vue reads props.__v_isReadonly
    console.log(replace.mock.calls.length) // > 0: camelCase/kebabCase ran for "__v_isReadonly"
    return () => h('i')
  }
}))

To see the cost in a real app: run node --cpu-prof .output/server/index.mjs, request a page withlook at camelCase/kebabCase/propIsDefined together with isReadonly, isRef, toRaw andreactivePick inside the useComponentProps get trap.

Description

useComponentProps returns a Proxy whose get trap returns early only for __v_isReactive and __v_raw. Vue and VueUse also read other internal flags on that proxy all the time: __v_isReadonly, __v_isShallow, __v_isRef and __v_skip. isReadonly, isRef, unref, toRaw, reactive(), reactivePick and toReactive all do this, and useForwardProps(pickLinkProps(props)) in UButton/ULink triggers it for every forwarded prop.

Each of those reads goes through the whole prop-resolution path:

  • Reflect.get on the props
  • theme lookup in defaults.value
  • propIsDefined(), which runs two String.replace regexes (camelCase + kebabCase)
  • appConfig.ui[name].defaultVariants lookup
  • vm.type.props[prop] lookup

and then always returns undefined, because no component declares a __v_* prop.

On our production SSR build, one UButton used as a link costs about 1 ms of server CPU per render. A route list with ~50 buttons spends a noticeable share of each request in this trap.

Additional context

`__v_isReactive` and `__v_raw` are already handled, so other `__v_*` keys reaching the prop path looks like an oversight rather than intent. The return value stays `undefined` either way, so the early return doesn't change behaviour: `isReadonly()`/`isShallow()` give the same results as now.

### Logs

```shell-script

Activity

  1. added
    triageAwaiting initial review and prioritization
    on Oct 11, 2026
  2. added theissue type on Oct 11, 2026
  3. changed the title [-]perf: `useComponentProps` treats Vue's internal `__v_*` flag reads as prop lookups (regex + theme lookups on every probe)[/-] [+]perf(useComponentProps): treats Vue's internal `__v_*` flag reads as prop lookups (regex + theme lookups on every probe)[/+] on Oct 12, 2026
  4. removed
    triageAwaiting initial review and prioritization
    on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions