Dexie Cloud behavior: Operations are undone when syncing #2024
Replies: 1 comment
-
Thanks for the tip @dfahlander. I was able to use this method to see the rejection message. Unfortunately, I'm still not quite sure how to solve the problem. I have a feeling it's something to do with not managing my schema versions and migrations correctly. I have created a "config" table, that I want to store app configuration in. It was simply meant to be a key/value store, e.g. type Config = {
key: string;
value: string;
}; I added it to the latest version of the schema. I didn't create a version 3, which I think I should have: export class MyDexieDb extends Dexie {
// other tables
// ...
config: DexieCloudTable<Config, 'key'>;
constructor() {
const addons = [dexieCloud];
super('MyDexieDb', { addons });
this.version(1).stores({
otherTable: `@id`,
// ...
});
this.version(2).stores({
anotherTableCreatedEarlier: `@id`,
config: `key`
});
}
} I had a function that I ran to populate the various tables whenever the user was logged in and syncing complete. Within that function I was checking for entries in the I see the I've also exported the data using the CLI tool using This is only happening for one of my dev test accounts. I have a prod account that's currently working and has the same key/value in the |
Beta Was this translation helpful? Give feedback.
-
In Dexie Cloud, if the server need to reject a change, it will send updates to the client that will reset it to the same state as the server - without the requested changes - it could be added objects, updated properties or deleted objects. The reason for this is a principle that Dexie Cloud always keep: After sync, the partial database of the client will mirror exactly the corresponding part on the server. Logically, if the client changes was rejected by the server, it needs to reset the client as if the changes were never done.
If you ever experience this behavior, make sure to open Devtools and look in the Network tab and inspect the content of the sync response. You will find a property "rejections".
It's an array of exceptions and the corresponding transaction ID for any of the reasons mentioned below:
If you have any questions regarding this behavior, you are welcome to discuss it here.
Beta Was this translation helpful? Give feedback.
All reactions