-
Notifications
You must be signed in to change notification settings - Fork 51
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
Timeout in DocHandle waitFor prevents process from exiting. #235
Comments
I also had this issue of having // Create your `Repo`
const adapter = new BrowserWebSocketClientAdapter(`ws://localhost:${PORT}`);
const repo = new Repo({
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 handle
Object.values(repo.handles).forEach((handle) => {
// @ts-ignore `stop` has been added manually through a patch
handle.stop();
}); For context, here's stop() {
this.#machine.stop();
} Provided guidance and strong PoV on the right technical strategy, very happy to contribute the changes needed. |
@dmaretskyi @pvh it would be great to have your insights on this. |
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 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: