You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I also had this issue of having automerge-repo processes not stopping with NodeJS. For each Repo I have created, I need to do the following to close down all intervals & sockets:
// Create your `Repo`constadapter=newBrowserWebSocketClientAdapter(`ws://localhost:${PORT}`);constrepo=newRepo({network: [adapter],// ...})// I disconnect `Repo` from the server:adapter.disconnect()adapter.peerId=undefined;// if not done, it will reconnect automatically.adapter.socket?.close();// stop each handleObject.values(repo.handles).forEach((handle)=>{// @ts-ignore `stop` has been added manually through a patchhandle.stop();});
For context, here's DocHandle's stop method that I had to add through a patch:
stop(){this.#machine.stop();}
Provided guidance and strong PoV on the right technical strategy, very happy to contribute the changes needed.
ah yeah, this is just unfinished work i haven't felt enough pain from to fix yet.
a repo.stop() would be a good short-term workaround but really we probably also want something like repo.allSynced() or something as well.
broadly speaking the design here is something along the lines of "for short-lived processes there should be a way to gracefully exit when a task is done" and i think the "when a task is done" is going to be the more involved part.
The
waitFor
helper called here is creating asetTimeout
that doesn't get cleared which prevents the node.js process from exiting.They can be seen when running wtfnode after creating documents with automerge.
I believe this could be fixed by adding another final
CLOSED
state toDocHandle
and a method toRepo
that transitions all doc handles into that state.The text was updated successfully, but these errors were encountered: