Skip to content

Error when adding object with [undefined] array property to a synced list: `c is undefined #136

@aabidsofi19

Description

@aabidsofi19

Description:

When adding an object to a list managed by syncedStore, if the object contains an array property that includes undefined as a value (e.g., [undefined]), an error is raised:

Uncaught TypeError: c is undefined

This issue seems to originate from internal assumptions that all array values are either null or valid serializable types, and fails to gracefully handle undefined entries.

🔁 Steps to Reproduce:

  1. Create a synced store.
  2. Push an object into a synced array where one of the properties is [undefined].

💥 Reproduction Example:

import { syncedStore, getYjsDoc } from '@syncedstore/core';

const store = syncedStore({ items: [] });

store.items.push({
  name: 'test',
  data: [undefined], // this causes the error
});

🧪 Expected Behavior:

The object should be added to the list without error, or at minimum undefined values should be gracefully converted (e.g., to null)

🐛 Actual Behavior:

Throws:

Uncaught TypeError: c is undefined

TypeError: c is undefined
    typeListInsertGenericsAfter webpack-internal:///./node_modules/yjs/dist/yjs.mjs:5539
    typeListInsertGenericsAfter webpack-internal:///./node_modules/yjs/dist/yjs.mjs:5535
    typeListInsertGenerics webpack-internal:///./node_modules/yjs/dist/yjs.mjs:5591
    insert webpack-internal:///./node_modules/yjs/dist/yjs.mjs:5981
    transact webpack-internal:///./node_modules/yjs/dist/yjs.mjs:3525
    insert webpack-internal:///./node_modules/yjs/dist/yjs.mjs:5980
    _integrate webpack-internal:///./node_modules/yjs/dist/yjs.mjs:5920
    integrate webpack-internal:///./node_modules/yjs/dist/yjs.mjs:9606
    integrate webpack-internal:///./node_modules/yjs/dist/yjs.mjs:10150
    typeMapSet webpack-internal:///./node_modules/yjs/dist/yjs.mjs:5753
    set webpack-internal:///./node_modules/yjs/dist/yjs.mjs:6320
    transact webpack-internal:///./node_modules/yjs/dist/yjs.mjs:3525
    set webpack-internal:///./node_modules/yjs/dist/yjs.mjs:6319
_app.js:327933:25

This makes it difficult to debug and can unexpectedly crash apps that rely on dynamic data using syncedStore.

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