[BUG] Uncaught TypeError: sharedType.toJSON is not a function
arvinxx opened this issue · comments
Describe the bug
I'm try to intergrate into our product, but I found a problem:
Uncaught TypeError: sharedType.toJSON is not a function
at patchSharedType (yjs.mjs:293:1)
at yjs.mjs:341:1
at Array.forEach (<anonymous>)
at patchSharedType (yjs.mjs:294:1)
at yjs.mjs:344:1
at Array.forEach (<anonymous>)
at patchSharedType (yjs.mjs:294:1)
at yjs.mjs:341:1
at Array.forEach (<anonymous>)
at patchSharedType (yjs.mjs:294:1)
at yjs.mjs:341:1
at Array.forEach (<anonymous>)
at patchSharedType (yjs.mjs:294:1)
at yjs.mjs:464:1
at transact (yjs.mjs:3292:1)
at Doc.transact (yjs.mjs:505:1)
at yjs.mjs:463:1
![image](https://private-user-images.githubusercontent.com/28616219/244244502-9b8e9324-632f-49e4-9205-a61c061a40e4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIzODIyMjksIm5iZiI6MTcyMjM4MTkyOSwicGF0aCI6Ii8yODYxNjIxOS8yNDQyNDQ1MDItOWI4ZTkzMjQtNjMyZi00OWU0LTkyMDUtYTYxYzA2MWE0MGU0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzMwVDIzMjUyOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTgwZWMxMGZjYjg1MGJiZWIyNmNiMDhkMDgwMGY3MGFkNDBiODllNTM1NjJlY2I3YTc3M2FlNDllNjJmY2IzMWImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.pElxXWNIMJ0htCUJqjpeHCg5KjIqlyxNC6bbpnGIErQ)
here is my data snapshot:
![image](https://private-user-images.githubusercontent.com/28616219/244245550-97da1d65-415f-4848-aa8e-8ddfbb6993ab.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIzODIyMjksIm5iZiI6MTcyMjM4MTkyOSwicGF0aCI6Ii8yODYxNjIxOS8yNDQyNDU1NTAtOTdkYTFkNjUtNDE1Zi00ODQ4LWFhOGUtOGRkZmJiNjk5M2FiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzMwVDIzMjUyOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM4ZjU5OTljNzZhYmQ4YmQwNWQzMDJjNzNlNmYwZjNhNDMwNzAwNzA3ZTg1MDFjOWU5Zjg4ZTQ0ZGZmYzY4MWYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Yu8N8B887FfrQYEo2s6KUaKIub0P3i9D-zpu7iPyIwA)
Screenshots
Versions (please complete the following information):
- Browser [e.g. chrome, safari] Chrome
- Version [e.g. 22] 1.3.0
Additional context
Add any other context about the problem here.
I'm going to need a minimal reproduction to debug this. Can you set up a CodeSandbox or repo that reproduces this error? Or at least the full JSON of your data snapshot instead of a screencap?
I've got the same error. I made a CodeSandbox example.
Reproduction steps:
- Open devtools
- Click on test
- Click on test2. You should see the error in the console
(You may have to open a second tab with the same page before step 2/3) - If you repeat clicking on any of the text items you should see the error repeat
I initially thought it might be an issue with the immer
Zustand extension. But I removed it from the code and still got the error.
Thanks Alex!
From debugging your example, the bug is obvious: I forgot to convert strings to YText objects before shoving them in Yjs...
I'll get that fixed as soon as I have the time!
Release 1.3.1 fixes this issue, so going to close for now. If something else is broken, don't hesitate to reopen it!