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

Malformatted Revision in getHeightOfRevision (Supabase Example) #6831

Open
hagemon opened this issue Feb 6, 2025 · 4 comments
Open

Malformatted Revision in getHeightOfRevision (Supabase Example) #6831

hagemon opened this issue Feb 6, 2025 · 4 comments

Comments

@hagemon
Copy link

hagemon commented Feb 6, 2025

I’m integrating the Supabase example into my project ([email protected]), but inserting a new object results in the following error:

ERROR
malformatted revision: 
getHeightOfRevision@http://localhost:8888/bundle.js:47171:18
createRevision@http://localhost:8888/bundle.js:47178:69
@http://localhost:8888/bundle.js:64444:81

After inspecting createRevision, I found that _rev from previousDocData is used to generate newRevisionHeight. However, logging docData in preInsert (which corresponds to previousDocData in createRevision) shows that _rev is an empty string:

database.heroes.preInsert((docData) => {
    console.log((docData as any));
    docData.replicationRevision = createRevision(
        database.token,
        docData as any
    );
    return docData;
}, false);
/* output
{
    "name": "111",
    "color": "111",
    "updatedAt": 1738859213138,
    "replicationRevision": "1",
    "_meta": {
        "lwt": 1
    },
    "_deleted": false,
    "_attachments": {},
    "_rev": ""  // empty string here
}
*/

Manually adding _rev in the insert handler makes it work, but I’m unsure if this is a proper workaround:

(insertButton as any).onclick = async function () {
    const name = (document.querySelector('input[name="name"]') as any).value;
    const color = (document.querySelector('input[name="color"]') as any).value;
    const obj = {
        name: name,
        color: color,
        updatedAt: new Date().getTime(),
        replicationRevision: '1',
        _rev: '1-' + Math.random() // manually set the _rev
    };
    await database.heroes.insert(obj);
    (document.querySelector('input[name="name"]') as any).value = '';
    (document.querySelector('input[name="color"]') as any).value = '';
};

Is _rev expected to be set manually before insertion, or is this a bug in the example? Looking for guidance on the correct approach.

@pubkey
Copy link
Owner

pubkey commented Feb 6, 2025

No it should not be required to manually set revisions. Please make a PR with a unit test or something that reproduces your problem.

@hagemon
Copy link
Author

hagemon commented Feb 8, 2025

Thanks for your reply!

I run the given unit tests in e2e.test.js with STORAGE=memory npm run test:e2e and set testcafe run in both safari and edge (because I don't use chrome) by editing package.json

{
    "test:e2e": "testcafe safari -e test/ --hostname localhost"
}

then I met the same error in TestCafe:

Image

The output log:

> [email protected] test:e2e
> testcafe safari -e test/ --hostname localhost

 Running tests in:
 - Safari 18.1.1 / Sequoia 15

 Example page
start test insert/remove a hero
waitUntilPageIsLoaded()
logs:
{
  log: [
    '[HMR] Waiting for update signal from WDS...',
    'run() [object Object]',
    'storageKey: memory',
    'emitted heroes:',
    'minTimestamp: 0',
    'STATUS changed',
    'pull data:',
    'minTimestamp: 1738859777170',
    'pull data:'
  ],
  info: [
    '[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.'
  ],
  warn: [
    'some dev mode warning'
  ],
  error: []
}
waitUntilPageIsLoaded(): done
logs:
{
  log: [
    '[HMR] Waiting for update signal from WDS...',
    'run() [object Object]',
    'storageKey: memory',
    'emitted heroes:',
    'minTimestamp: 0',
    'STATUS changed',
    'pull data:',
    'minTimestamp: 1738859777170',
    'pull data:'
  ],
  info: [
    '[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.'
  ],
  warn: [
   'some dev mode warning...'
  ],
  error: []
}
deleteAll()
logs:
{
  log: [
    '[HMR] Waiting for update signal from WDS...',
    'run() [object Object]',
    'storageKey: memory',
    'emitted heroes:',
    'minTimestamp: 0',
    'STATUS changed',
    'pull data:',
    'minTimestamp: 1738859777170',
    'pull data:'
  ],
  info: [
    '[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.'
  ],
  warn: [
    '-------------- RxDB dev-mode warning -------------------------------\n' +
      'you are seeing this because you use the RxDB dev-mode plugin https://rxdb.info/dev-mode.html?console=dev-mode \n' +
      'This is great in development mode, because it will run many checks to ensure\n' +
      'that you use RxDB correct. If you see this in production mode,\n' +
      'you did something wrong because the dev-mode plugin will decrease the performance.\n' +
      '\n' +
      '🤗 Hint: To get the most out of RxDB, check out the Premium Plugins\n' +
      'to get access to faster storages and more professional features: https://rxdb.info/premium/?console=dev-mode \n' +
      '\n' +
      'You can disable this warning by calling disableWarnings() from the dev-mode plugin.\n' +
      '---------------------------------------------------------------------'
  ],
  error: []
}
wait until the hero is emitted in the query
wait until the hero is emitted in the query
wait until the hero is emitted in the query
wait until the hero is emitted in the query
wait until the hero is emitted in the query
wait until the hero is emitted in the query
wait until the hero is emitted in the query
wait until the hero is emitted in the query
wait until the hero is emitted in the query
wait until the hero is emitted in the query
wait until the hero is emitted in the query
^CStopping TestCafe...

@pubkey
Copy link
Owner

pubkey commented Feb 8, 2025

Can you make a PR with that so that the CI fails? Shouldnt this also fail in chrome and firefox? Or is it browser specific?

Copy link

stale bot commented Feb 18, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed soon. Please update it or it may be closed to keep our repository organized. The best way is to add some more information or make a pull request with a test case. Also you might get help in fixing it at the RxDB Community Chat If you know you will continue working on this, just write any message to the issue (like "ping") to remove the stale tag.

@stale stale bot added the stale label Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants