Skip to content
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

Clarify use of sync. Closes #2298 #2303

Merged
merged 11 commits into from
Sep 16, 2024

Conversation

corrideat
Copy link
Member

@corrideat corrideat commented Aug 16, 2024

Fix #2298

@corrideat corrideat requested a review from taoeffect August 16, 2024 19:49
Copy link

cypress bot commented Aug 16, 2024

group-income    Run #3144

Run Properties:  status check passed Passed #3144  •  git commit b60a61c82f ℹ️: Merge d05123d8b40f0052ec3ecd9e7aa62a43ae9c7539 into 2e6183c6a4cf47b9719b35a30402...
Project group-income
Branch Review feature/2298-fix-confused-and-updated-sync-situation
Run status status check passed Passed #3144
Run duration 09m 21s
Commit git commit b60a61c82f ℹ️: Merge d05123d8b40f0052ec3ecd9e7aa62a43ae9c7539 into 2e6183c6a4cf47b9719b35a30402...
Committer Ricardo Iván Vieitez Parra
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 10
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 111
View all changes introduced in this branch ↗︎

Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @corrideat! Some questions

frontend/controller/actions/identity.js Show resolved Hide resolved
frontend/controller/actions/utils.js Show resolved Hide resolved
frontend/controller/app/identity.js Outdated Show resolved Hide resolved
frontend/controller/actions/index.js Show resolved Hide resolved
@corrideat corrideat force-pushed the feature/2298-fix-confused-and-updated-sync-situation branch from f8bb009 to f992d55 Compare August 30, 2024 15:16
@corrideat
Copy link
Member Author

Updated!

Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the build is failing and we need to re-run it anyway, can you push a commit with an elaborated comment?

frontend/controller/actions/utils.js Outdated Show resolved Hide resolved
@corrideat corrideat force-pushed the feature/2298-fix-confused-and-updated-sync-situation branch from a858784 to d71ad21 Compare September 15, 2024 19:46
Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concern:

Comment on lines 72 to 86
const listener = () => { reset = true }
this.ephemeral.ondestroy = () => {
destroyed = true
sbp('okTurtle.events/off', CHELONIA_RESET, listener)
syncPromise.finally(() => {
if (reset) return
sbp('chelonia/contract/release', this.ephemeral.groupIdWhenMounted, { ephemeral: true }).catch(e => {
console.error('[PendingApproval.vue]: Error releasing contract', e)
})
})
}
sbp('okTurtle.events/on', CHELONIA_RESET, listener)
},
beforeDestroy () {
this.ephemeral.ondestroy?.()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is all of this new logic and why has it been added here?

I'm not sure this is a good idea... did you test this with multiple groups? It's possible that beforeDestroy could be called as a result of the group switcher switching to a different group. If that happens it would break the joining attempt on the new group that we're trying to join.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't really new logic, rather redefining the old logic that called /sync, which is unsafe to call.

It's possible that beforeDestroy could be called as a result of the group switcher switching to a different group

I don't see how that'd break anything. The onDestroy is there to call release, which is the correct thing to do after calling retain. If the view is destroyed, there's no point in keeping the group around (if it shouldn't be released, the reference count should indicate that). Note that before this only called sync and it also didn't affect the reference count.

did you test this with multiple groups?

No, I'm not sure how that'd be done as joining a group would open a new URL?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I'm not sure how that'd be done as joining a group would open a new URL?

You'd create and join group1 as u1. Then u2 (in a separate container tab or browser) would send you an invite link to group2, but before u1 visits it, u2 would log out. Then u1 visits the link to join u2's group2 and get stuck on this pending page. Then they'd switch back to their own group. Then u2 would log back in.

I don't see how that'd break anything. The onDestroy is there to call release, which is the correct thing to do after calling retain. If the view is destroyed, there's no point in keeping the group around (if it shouldn't be released, the reference count should indicate that). Note that before this only called sync and it also didn't affect the reference count.

I see. Could you add a comment here as well then to explain where the "real" (persistent) retain happens on this group and why we're calling ephemeral retain here instead of sync?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd create and join group1 as u1. [...]

I did this and nothing broke, as expected, since this is merely a UI concern.

Could you add a comment here as well then

Done. Also added a comment to the effect that vue files should not be managing references.

Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved! Fantastic work @corrideat!

@taoeffect taoeffect merged commit e8d5fcd into master Sep 16, 2024
4 checks passed
@taoeffect taoeffect deleted the feature/2298-fix-confused-and-updated-sync-situation branch September 16, 2024 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix confused and outdated 'chelonia/contract/sync' situation
2 participants