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

misc push-related fixes and improvements #2649

Merged
merged 31 commits into from
Feb 22, 2025
Merged

misc push-related fixes and improvements #2649

merged 31 commits into from
Feb 22, 2025

Conversation

taoeffect
Copy link
Member

@taoeffect taoeffect commented Feb 18, 2025

Related to issues #2647 and #2653

@taoeffect taoeffect requested a review from corrideat February 18, 2025 21:02
@taoeffect taoeffect changed the title misc fixes and improvements misc push-related fixes and improvements Feb 18, 2025
Copy link

cypress bot commented Feb 19, 2025

group-income    Run #4062

Run Properties:  status check passed Passed #4062  •  git commit 89832ef35f ℹ️: Merge 9af8fa7ee313bf13a6bc92a21592f2d53589ef00 into 722036bccbf186eda94a89354682...
Project group-income
Branch Review 2647-fix-push
Run status status check passed Passed #4062
Run duration 11m 28s
Commit git commit 89832ef35f ℹ️: Merge 9af8fa7ee313bf13a6bc92a21592f2d53589ef00 into 722036bccbf186eda94a89354682...
Committer Greg Slepak
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 114
View all changes introduced in this branch ↗︎

@corrideat
Copy link
Member

corrideat commented Feb 19, 2025

I've added comments where appropriate, mostly explaining why certain things are the way they were. I'm not too happy (meaning feeling neutral to negative) with the changes made to the frontend management logic (other than the extra logging and the bugfix for reported, using reported.endpoint, which I feel positive about), but it does look like the Vue components had some improvements.

However, I don't think these changes will help much with the issue at hand, namely notifications stopping working after an update. This is why:

  1. On Slack, we've discussed these various 401 errors. I think getting to the bottom of this is what will fix the issue, or at least, it's a necessary condition.
  2. You seem to be making an effort at increasing the reliability of reporting the subscription to the server. Without focusing on whether the changes accomplish this or not, doing so will likely have little effect (*) on the issue at hand. When a subscription is first reported, the server stores it, and, after that, subsequent failures to report it again (e.g., new WS connections) would result in unnecessary push events being sent by the server, rather than fewer. This is because reporting a subscription actually causes the server to stop sending push events until that WS connection is closed. So, even if the reporting reliability is improved, the issue of notifications not being seen more than likely lies on the server.

(*) There's one exception to this, but it still requires an error on the server. That is, if the logic for storing subscriptions on the DB is faulty, and some or all subscriptions are lost.

@taoeffect
Copy link
Member Author

taoeffect commented Feb 20, 2025

@corrideat I've addressed all remaining feedback, please check latest changes!

Note: I wasn't able to join groups when creating a link in FF and then joining in Safari.

Also in both Safari and Brave I noticed this upon creating a group:

Screenshot 2025-02-20 at 1 38 36 PM

However upon dismissing I saw that I was joined.

I don't think these issues have anything to do with this PR but might be related to some of that commented out code (#2653) or other issues. Opened an issue for this: #2654

backend/push.js Outdated
Comment on lines 71 to 72
await deleteSubscriptionFromIndex(subscriptionId)
await sbp('chelonia.db/delete', `_private_webpush_${subscriptionId}`)
Copy link
Member

Choose a reason for hiding this comment

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

I realise this was like this from before, but I'm wondering if maybe the order of these two operations should be reversed

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know, if there's a strong reason for it that can be given I'm certainly happy to do it.

Copy link
Member

Choose a reason for hiding this comment

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

The reason is that if the deletion fails, then it'll still be in the index.

Copy link
Member Author

Choose a reason for hiding this comment

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

How will reversing the order fix that? It first deletes from the index right now. If there's a problem with writing to the DB, it's the index deletion that will fail first, and then it won't get to deleting the subscriptionID.

Whereas, if it successfully deletes the subscription key, but then fails to delete it from the index, it will be in the index but won't exist.

Copy link
Member

Choose a reason for hiding this comment

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

It doesn't 'fix' it, but it being in the index but not existing is worse than the converse, based on the assumption that keys may not be enumerable.

@@ -219,6 +174,7 @@ export const postEvent = async (subscription: Object, event: ?string): Promise<v
// Note: web push notifications can be 'bodyless' or they can contain a body
// If there's no body, there isn't anything to encrypt, so we skip both the
// encryption and the encryption headers.
// console.debug(`postEvent to ${subscription.id}:`, event)
Copy link
Member

Choose a reason for hiding this comment

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

Stray debug?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's OK to leave here just in case someone is debugging this part of the code. I found it useful and that's why I decided to comment it out instead of removing it completely. If you really want me to remove it I can though.

'service-worker/setup-push-subscription': async function (retryCount?: number) {
if (process.env.CI) {
'service-worker/setup-push-subscription': async function (attemptNumber = 1) {
if (window.Cypress || process.env.CI) {
Copy link
Member

Choose a reason for hiding this comment

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

Not a strong feeling either way, but the reason I was not checking for window.Cypress (and generally avoid doing so) is that these are runtime checks (code shipped) while process.env.CI is exclusively a buildtime check (no code shipped).

Copy link
Member Author

Choose a reason for hiding this comment

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

Had to add it because without it the tests weren't passing. An alternative would be to create a Cypress envvar in Gruntfile.js...

@corrideat
Copy link
Member

I've been reviewing this and testing it, and it seems like most things work. I didn't yet test this as comprehensively as the previous code (esp. re. the frontend parts), but it looks like it should work.

Can you as a last change request:

  1. Fix the order for deleting subscriptions before updating the index
  2. Revert the change to shared/domains/chelonia/chelonia.js
  3. Save this setting to IndexedDB in setNotificationEnabled and use it in the relevant places. Actually, the Vuex setting may not be needed at all if using IndexedDB.

@taoeffect taoeffect merged commit 710b80e into master Feb 22, 2025
4 checks passed
@taoeffect taoeffect deleted the 2647-fix-push branch February 22, 2025 18:48
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.

2 participants