Skip to content

TypeError: Cannot redefine property: data-scope when used with Ark UI / Zag.js components #363

Description

@PetukhovArt

Reproduction

SolidJS app using any Ark UI component (e.g. @ark-ui/solid's DatePicker, Popover — all use Zag.js under the hood) with @solid-devtools/overlay attached throws at runtime as soon as the component mounts:

Uncaught TypeError: Cannot redefine property: data-scope
    at observed_props_observe_prop (inspector.ts:142)

Root cause

Zag.js sets data-scope, data-part, and similar data-* attributes on the props object via Object.defineProperty with configurable: false (intentional — they're identity markers Zag relies on).

observed_props_observe_prop in packages/debugger/src/inspector/inspector.ts unconditionally calls Object.defineProperty(observed.props, key, { get, enumerable: true }) to monkey-patch a tracking getter. Redefining a non-configurable own property is a JavaScript TypeError — the debugger crashes the host app.

Suggested fix

Skip tracking when the existing descriptor is non-configurable (and wrap in try/catch as a belt-and-braces guard):

let existing = Object.getOwnPropertyDescriptor(observed.props, key)
if (existing && existing.configurable === false) return o

try {
    Object.defineProperty(observed.props, key, {
        get() { /* ...existing tracking getter... */ },
        enumerable: true,
        configurable: true,   // <- also add, current code omits it
    })
} catch {
    // non-configurable prop — skip tracking
}

Losing tracking on a handful of data-* marker props has no practical downside; crashing the app does.

Environment

  • @solid-devtools/overlay 0.33.5
  • @ark-ui/solid (latest, via Zag.js)
  • solid-js 1.9.x
  • Chromium (Tauri 2 webview) and standalone Chrome — both affected

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions