Skip to content

YjsPersister errors in case startAutoLoad is run before startAutoSave #186

@nikgraf

Description

@nikgraf

Describe the bug

This is the error I see:

Error: Content is not an array undefined
    at errorNew (/node_modules/tinybase/persisters/persister-yjs/index.js:36:9)
    at _callee2$ (/node_modules/tinybase/persisters/persister-yjs/index.js:447:27)
    at tryCatch (/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:45:16)
    at Generator.eval (/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:133:17)
    at Generator.eval [as next] (/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:74:21)
    at asyncGeneratorStep (/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:17)
    at _next (/node_modules/@babel/runtime/helpers/asyncToGenerator.js:17:9)

The issue is if I run startAutoSave before startAutoLoad it wipes the Yjs object.

Your Example Website or App

https://codesandbox.io/p/sandbox/x77hnc

Steps to Reproduce the Bug or Issue

Run this code:

const doc1 = new Doc();
const store1 = createStore();
const persister1 = createYjsPersister(store1, doc1, "space", (error) => {
  console.log("YjsPersister Error:", error);
});
await persister1.startAutoLoad();
await persister1.startAutoSave();

Expected behavior

Graceful handling of the error

Screenshots or Videos

No response

Platform

  • Tinybase 5.3

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    as designedI think this is how it is supposed to work...

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions