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

Failed test with initial schema hack #445

Closed
wants to merge 1 commit into from

Conversation

okdistribute
Copy link

@okdistribute okdistribute commented Nov 10, 2021

This test fails after I save and then re-load the document. If you remove lines 1445 and 1446, the tests pass. If you port this test to preview.4, the test passes. So this seems to be a bug somewhere between preview.4 and preview.5. I did a git bisect and found that hash 325f9e8 is the first bad commit.

This is a hack for supporting branching and merging from unrelated documents that were created within the same app. It is not directly supported by the Automerge API, which is probably how the bug snuck through. I think it's important to make this hack more automatic in the Automerge API. If I get some time to think about it I can say more or make a suggestion about how the API should work. Without this, there is no way to get reliable behavior for merging two branched documents that don't start with a single author.

√ automerge % npm test test/test.js

  Automerge
    changes API
      1) should apply changes from another document initialized with the same schema


  0 passing (37ms)
  1 failing

  1) Automerge
       changes API
         should apply changes from another document initialized with the same schema:
     RangeError: Expected seq 2, got seq 1 from actor 0000
      at applyChanges (backend/new.js:1536:15)
      at BackendDoc.applyChanges (backend/new.js:1778:35)
      at Object.applyChanges (backend/backend.js:29:23)
      at Object.applyChanges (src/automerge.js:93:37)
      at Context.<anonymous> (test/test.js:1448:36)
      at processImmediate (internal/timers.js:461:21)

EDIT: On further investigation, I found that changeIndexByHash does not contain actor 0000 in the re-hydrated version of the document. https://github.com/automerge/automerge/blob/main/backend/new.js#L1523

@okdistribute okdistribute changed the title failing test with schema test with schema Nov 10, 2021
@ept
Copy link
Member

ept commented Nov 10, 2021

Yes, we definitely need to improve this. See also issues #4 and #374 for previous discussions of the same problem. If you want to have a go at fixing this, I can help you get started.

@okdistribute okdistribute changed the title test with schema Failed test with initial schema Nov 13, 2021
@okdistribute okdistribute changed the title Failed test with initial schema Failed test with initial schema for merging branched documents Nov 13, 2021
@okdistribute okdistribute changed the title Failed test with initial schema for merging branched documents Failed test with initial schema hack Nov 13, 2021
ept added a commit that referenced this pull request Nov 15, 2021
@ept
Copy link
Member

ept commented Nov 15, 2021

Thanks for the test case. I think I've fixed the bug on #446 — can you give it a try?

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 this pull request may close these issues.

2 participants