Code Monkey home page Code Monkey logo

Comments (3)

acurrieclark avatar acurrieclark commented on August 18, 2024

Interesting. I would say the second option is preferable to an arbitrary timeout. Or at the very least have some way of exposing to users that the network is not ready before they request a document.

I would have thought that the current implementation does commence sync for an unavailable doc automatically when a new peer connects. If not, I would say it should anyway?

from automerge-repo.

alexjg avatar alexjg commented on August 18, 2024

We can implement beginning sync for an unavailable document when a new peer connects quite easily. Right now that would still be an awkward API though I think because it sort of makes the "unavailable" status less useful. In the snippet above the user would have to always wait on whenReady with some kind of timeout regardless of whether the document resolved as unavailable because they would still need to wait for the network to start up.

I think instead having a kind of "network ready" state for the whole repo might be what is required. That way the user waits for "network ready" and then if a document is unavailable they know that it's not down to the network waiting to come up.

from automerge-repo.

pvh avatar pvh commented on August 18, 2024

I've been fighting with this a little bit lately. In trail-runner network connections can come and go in the frontend as ServiceWorkers get replaced. My solution right now is to block on calling find until I've set up a network connection but I don't think this is necessarily the best approach.

I think the issue here is that "network ready" isn't monotonic (your network might report being online prematurely or might go offline again as you travel through a tunnel) and also you may already have all the data you need locally. find() only returns undefined if you don't have the data yet!

In TEE, @geoffreylitt uses a loading screen to guard against trying to do things before connecting. I don't think that's quite the right approach either but it suggests there may be options here.

One thing I've been meaning to do for a while is to start exposing some kind of explanations for why a document didn't load. Was it that there were no peers, that there were peers but nobody would give you the document, was the file corrupted, or was it a bogus input? So many ways to fail.

from automerge-repo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.