fix: [SDK-4874] prevent stale UpdateSubscription leaving users Never Subscribed#1687
Conversation
…ibed - Coalesce unsent UpdateSubscription requests per subscription and rebuild the PATCH body from the live model before send - Motivation: a pre-permission -19 snapshot meaning PROMPTED BUT NOT YET ANSWERED cannot overwrite a later grant as requests are sent async Co-Authored-By: Cursor <cursoragent@cursor.com>
|
Core approach looks good. Two concerns: refreshParametersFromLiveModel() omits device_model, net_type, and test_type, so those updates are no longer sent. |
"No longer sent" is not quite accurate, this is existing and it is not sent currently. And for subscription updates, those things don't really need updating, they are not really used nor change after an app is already installed.
Called out in PR that it does not serialize already in-flight PATCHes (follow-up if needed). Omitted as out of scope for this PR, as it is possible but very hard to hit, in favor of a larger planned refactor of operation repo / executors. |
Description
One Line Summary
Prevent a stale pre-permission UpdateSubscription (
notification_types: -19) from overwriting a later permission grant and leaving users stuck Never Subscribed.Details
Motivation
Rapid permission prompt acceptance can queue an UpdateSubscription while the push subscription is still in the “prompted but never answered” state (
enabled: false,notification_types: -19). That request may stay waiting to be sent. When it later flushes with another UpdateSubscription (enabled = true) request, its payload can race with or overwrite the most recent update due to timing of requests accepted by the server, leaving the server subscription disabled / Never Subscribed even though the user accepted.Fixes SDK-4874.
Scope
OSRequestUpdateSubscriptionrebuilds the PATCH body from the live subscription model inprepareForExecution(and drops the unusedsubscriptionObject).OSSubscriptionOperationExecutorkeeps at most one unsent UpdateSubscription per subscription model (last wins).SubscriptionUpdateRaceTests.-19entirely. Does not serialize already in-flight PATCHes (follow-up if needed).Testing
Unit testing
Added
SubscriptionUpdateRaceTests:prepareForExecutionpicks up liveenabled/notification_typesafter grant.Manual testing
Previously reproduced the race with demo app forced to enqueue conflicting UpdateSubscription requests; after the changes in this PR, the requests carry the current subscribed payload.
Affected code checklist
Checklist
Overview
Testing
SubscriptionUpdateRaceTestslocally (pass). Full CI pending on this PR.Final pass
Made with Cursor