Closed jessegrosjean closed 5 months ago
My expectation in the first scenario is that repo.find(id: DocumentId())
without a network connection should throw and Unavailable
error - it shouldn't resolve into a handle.
The second may well be expected behavior, depending on what you're remote repo is providing. That's something where I'd want to see the traces that you've enabled to see what's returned. I'm not sure if a find with a DocumentId() is equivalent conceptually to "please create, and then return to me, a new document" for the JS version of automerge-repo.
The only scenario I've significantly worked is "create the doc", disconnect, reconnect later, "request the doc" and verify that the handle resolves and the doc contents are equivalent.
The first is definitely a bug - created a test that illustrates it (https://github.com/automerge/automerge-repo-swift/pull/85)
The logic doesn't account for networking providers that have been added but aren't active to provide a response.
I replicated the second in an integration test (now also in #85 - second commit) with a local instance of sync server, and it behaved exactly as you found as well. Since the remote repo returned a value, I believe that's expected behavior.
I'm aiming to get a fix in for the obvious find bug (failing to accommodate inactive network providers) and then cut a point release with the fixes
found the hang, and fixing with https://github.com/automerge/automerge-repo-swift/pull/85 - it was actually more of a ludicrous timeout (300 seconds), waiting for responses that would never come, but the specific scenario of not having any active "peers" to request should be a short-circuit to Unavailable, which is what the PR enables.
I've found two unexpected (to me) behaviors with repo.find().
First in this scenario repo.find() never finishes and never errors:
And in this scenario (where I start web socket before repo.find()) I always successfully get a found handle with an associated document. This is unexpected because find seems to be acting more like create? I would expect some sort of "not found" error here, since the DocumentId should be unknown to the repo.
I think maybe first is a bug. Not sure if second is expected or not.