Skip to content

Cannot read properties of undefined (reading 'constructor') at memoizedCreateChangeProxy when reading new nested property #1417

Description

@filipw01
  • I've validated the bug against the latest version of DB packages

Describe the bug
When reading a newly added nested property TypeError: Cannot read properties of undefined (reading 'constructor') is thrown

To Reproduce

import { createChangeProxy } from '@tanstack/db'

type Row = {
  id: string
  nested?: {
    count: number
  }
}

const original: Row = {
  id: '1',
}

const { proxy, getChanges } = createChangeProxy(original)

console.log('Initial changes:', getChanges())

// This writes to changeTracker.copy_.nested
proxy.nested = { count: 1 }

console.log('After assigning nested object:', getChanges())

try {
  console.log(proxy.nested?.count)
} catch (error) {
  console.error('Reproduced proxy bug:')
  console.error(error)
}

Expected behavior
In the example above 1 is returned

  • OS: MacOS 26.3.1
  • Browser: Chrome 146.0.7680.165

Additional context
I was updating lodash mergeWith to es-toolkit/compat and found that tanstack db started throwing when merging some objects behind its proxy

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions