Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexedDBStore: createUser is undefined, it should be set with setUserCreator when upgrading 29.1.0 -> 30.3.0 #3986

Closed
WebFreak001 opened this issue Jan 5, 2024 · 2 comments · Fixed by #3987

Comments

@WebFreak001
Copy link
Contributor

WebFreak001 commented Jan 5, 2024

error:

Failed initializing matrix:  Error: createUser is undefined, it should be set with setUserCreator()!
    startup http://localhost:8080/node_modules/.vite/deps/chunk-AUCUNUAW.js?v=96c31d21:167359
    startup http://localhost:8080/node_modules/.vite/deps/chunk-AUCUNUAW.js?v=96c31d21:167357
    promise callback*startup http://localhost:8080/node_modules/.vite/deps/chunk-AUCUNUAW.js?v=96c31d21:167355
    startClient http://localhost:8080/src/client/initMatrix.js:42

API call:

    const indexedDBStore = new sdk.IndexedDBStore({
      indexedDB: global.indexedDB,
      localStorage: global.localStorage,
      dbName: 'web-sync-store',
    });
    await indexedDBStore.startup(); // <-- fails here

    this.matrixClient = sdk.createClient({
      baseUrl: secret.baseUrl,
      accessToken: secret.accessToken,
      userId: secret.userId,
      store: indexedDBStore,
      cryptoStore: new sdk.IndexedDBCryptoStore(global.indexedDB, 'crypto-store'),
      deviceId: secret.deviceId,
      timelineSupport: true,
      cryptoCallbacks,
      verificationMethods: [
        'm.sas.v1',
      ],
    });

the creation is almost exactly like what the API docs are suggesting to use, so I don't know what's going wrong here:

let opts = { indexedDB: window.indexedDB, localStorage: window.localStorage };
let store = new IndexedDBStore(opts);
await store.startup(); // load from indexed db
@WebFreak001
Copy link
Contributor Author

temporary workaround using undocumented as well as deprecated functions, but at least make it work for now:

call

indexedDBStore.setUserCreator(uid => new sdk.User(uid));

before .startup()

The setUserCreator API itself is undocumented, which probably means it wasn't meant to be exposed and was accidentally pushed as public API. I'd recommend not using it, even if it's mentioned in the error message.

introduced via #3796, cc @MidhunSureshR

WebFreak001 added a commit to WebFreak001/matrix-js-sdk that referenced this issue Jan 5, 2024
changes the changelog entry to include since when this change is needed

fix matrix-org#3986
WebFreak001 added a commit to WebFreak001/matrix-js-sdk that referenced this issue Jan 5, 2024
changes the changelog entry to include since when this change is needed

fix matrix-org#3986
@WebFreak001
Copy link
Contributor Author

in case users are supposed to call the APIs in a different order now, I have opened #3987 now that would update the documentation to reflect that.

That approach seems to work on my project and doesn't use any deprecated or undocumented APIs, but I don't know if it comes with any downsides since I'm not in too deep on the internal project structure.

WebFreak001 added a commit to WebFreak001/matrix-js-sdk that referenced this issue Jan 24, 2024
changes the changelog entry to include since when this change is needed

fix matrix-org#3986
WebFreak001 added a commit to WebFreak001/matrix-js-sdk that referenced this issue Jan 24, 2024
changes the changelog entry to include since when this change is needed

fix matrix-org#3986

Signed-off-by: WebFreak001 <[email protected]>
WebFreak001 added a commit to WebFreak001/matrix-js-sdk that referenced this issue Jan 24, 2024
changes the changelog entry to include since when this change is needed

fix matrix-org#3986

Signed-off-by: Jan Jurzitza <[email protected]>
github-merge-queue bot pushed a commit that referenced this issue Jan 25, 2024
* fix IndexedDBStore API documentation

changes the changelog entry to include since when this change is needed

fix #3986

Signed-off-by: Jan Jurzitza <[email protected]>

* retroactively add breaking change note to changelog entry

Signed-off-by: Jan Jurzitza <[email protected]>

---------

Signed-off-by: Jan Jurzitza <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant