diff --git a/packages/automerge-repo/src/DocHandle.ts b/packages/automerge-repo/src/DocHandle.ts index 367b4b53..55554b99 100644 --- a/packages/automerge-repo/src/DocHandle.ts +++ b/packages/automerge-repo/src/DocHandle.ts @@ -318,7 +318,13 @@ export class DocHandle extends EventEmitter> { * Creates a fixed "view" of an automerge document at the given point in time represented * by the `heads` passed in. The return value is the same type as docSync() and will return * undefined if the object hasn't finished loading. - * @returns + * + * @remarks + * Note that our Typescript types do not consider change over time and the current version + * of Automerge doesn't check types at runtime, so if you go back to an old set of heads + * that doesn't match the heads here, Typescript will not save you. + * + * @returns An Automerge.Doc at the point in time. */ view(heads: A.Heads): A.Doc | undefined { if (!this.isReady()) { diff --git a/packages/automerge-repo/test/Repo.test.ts b/packages/automerge-repo/test/Repo.test.ts index 66947b4e..d2459314 100644 --- a/packages/automerge-repo/test/Repo.test.ts +++ b/packages/automerge-repo/test/Repo.test.ts @@ -833,8 +833,7 @@ describe("Repo", () => { }) it("synchronizes changes from bobRepo to charlieRepo when loading from storage", async () => { - const { bobRepo, bobStorage, charlieRepo, aliceHandle, teardown } = - await setup() + const { bobRepo, bobStorage, teardown } = await setup() // We create a repo that uses bobStorage to put a document into its imaginary disk // without it knowing about it @@ -846,7 +845,6 @@ describe("Repo", () => { }) await bobRepo2.flush() - console.log("loading from disk", inStorageHandle.url) // Now, let's load it on the original bob repo (which shares a "disk") const bobFoundIt = bobRepo.find(inStorageHandle.url) await bobFoundIt.whenReady() @@ -855,6 +853,8 @@ describe("Repo", () => { // (This behaviour is mostly test-validation, we are already testing load/save elsewhere.) assert.deepStrictEqual(await bobFoundIt.doc(), { foo: "foundOnFakeDisk" }) + await pause(10) + // We should have a docSynchronizer and its peers should be alice and charlie assert.strictEqual( bobRepo.synchronizer.docSynchronizers[bobFoundIt.documentId]?.hasPeer(