-
Notifications
You must be signed in to change notification settings - Fork 87
State of Dochandle should be "ready" when change event is triggered #453
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
base: main
Are you sure you want to change the base?
Conversation
msakrejda
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the bug report and the fix! I have some minor comments, but overall it looks great.
|
|
||
| // If we didn't have the document yet, signal that we now do and return | ||
| // checkForChanges will then be triggered again by the state machine | ||
| // This ensures that when change is triggered the state is set to ready |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the comment: this definitely makes it easier to follow.
|
I'm pretty sure the CI failure is unrelated: https://github.com/automerge/automerge-repo/actions/runs/16046435722/job/45280996045?pr=453#step:6:797 -- it's an OOM. I'll try restarting the test and see if it's a recurring issue. |
|
@paulsonnentag are you interested in continuing this patch? It looks like the CI OOM is persistent, so we'd need to figure that out, but other than that and the minor cleanup I suggested, I think this is ready to merge, and it seems like a worthwhile change. If not, I can look into getting it over the finish line. |
|
Thanks for catching that. If you'd take over this PR I'd be very happy |
|
Hmm, so, I think this does break some existing assumptions somewhere. I was able to reproduce the CI failure, partly: the tests appear to hang. I'm guessing maybe we're leaking memory somehow during the hang and eventually we OOM. I do see a slow leak locally. I can take a look at it next week. |
When you subscribe to changes on a doc handle the first time the document loads the state on the handle is still "loading" in the change callback even though the document is already loaded.
Why is this happening? On each state transition we call
#checkForChangesthis function which has two responsibilities:Right now when the document is loaded for the first time
#checkForChangesemits a change event and then transitions the state machine from "loading" to "ready". That's why in the callback the state field on the handle is still loading. This pull request fixes this that we first transition into the ready state and then trigger a change event.