SyncedStore icon indicating copy to clipboard operation
SyncedStore copied to clipboard

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

Open aabidsofi19 opened this issue 11 months ago โ€ข 0 comments

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.

aabidsofi19 avatar May 05 '25 13:05 aabidsofi19