Repository navigation
fix: [SDK-5373] keep login waiters when a request gets no response (3/3) - #1579
fadi-george wants to merge 2 commits into
Conversation
abdulraqeeb33
left a comment
There was a problem hiding this comment.
This review is of the commits on top of #1577.
A missing response now keeps the waiter and retries, the same way a 5xx already does. The batch goes back on the queue with its waiter, the retry count increments, and the repo waits. Offline still does not send until navigator.onLine is true, because _getNextOps returns null. A later success resolves login(). A final 4xx, a pause, or an unhandled unauthorized result still rejects it. Any other throw still deletes the batch. The tests cover the waiter staying through the failure and resolving on the retry, including addEmail during the backoff.
An online no-response used to log "Op execute error" before the requeue. The return now happens first, so that path only logs the delay. Offline was already silent. FailRetry still logs the retry.
sherwinski
left a comment
There was a problem hiding this comment.
createSubscribedUser awaits _enqueueAndWait, and init() awaits it on auto-resubscribe. With this change init() and SDK_INITIALIZED wait until a retry gets a response. Consider using _enqueue there instead.
460fc7c to
7cdec35
Compare
A request that gets no response now keeps its operations and their waiters in the queue and retries with backoff, as FailRetry already does. login() resolves when a retry succeeds instead of rejecting on a network blip while the login completes in the background. Offline handling is unchanged: _getNextOps holds the queue. Co-Authored-By: Claude Opus 5.5 <[email protected]>
7cdec35 to
48769ff
Compare
|
|
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Follow-up: added a cap (af8c438). After 5 tries with no response (~2.5 min of backoff) the waiter rejects and the op stays queued, so a blocked API no longer holds |
Description
1 Line Summary
Keep
login()and other_enqueueAndWaitwaiters attached for the first few retries when a request gets no response, soawait OneSignal.login()resolves when a retry succeeds after a blip, and still rejects if the API stays unreachable.Details
Motivation
On main, when a request got no response while the browser was online, OperationRepo rejected the waiters but kept the ops queued (
0c8fdaac4).await login()rejected afterbase.ts's ~2 min of retries, even when a later retry logged the user in. #1577 removes those internal retries, so this rejection would come right away on any blip. A 5xx or 429 (FailRetry) already keeps the waiter, so a missing response should behave the same way.Scope
OperationRepocatch block: onRetryLimitError, requeue the ops with their resolvers and back off. This replaces the separate offline and online branches. Offline handling is unchanged, because_getNextOpsholds the queue whilenavigator.onLineis false.OP_REPO_MAX_WAITER_RETRIES(5, about 2.5 min of backoff), its waiter rejects withFailNoretryand the op stays queued, like main's ~2 min rejection.await login()now rejects on a final 4xx,FailPauseOpRepo, unauthorized, or after 5 tries with no response.login(sameId)return the earlier switch's promise. That branch is also the JWT refresh path after a 401, and returning a rejected promise there would faillogin(sameId, newToken)even though the retry uses the new token.Tradeoff
This reverses the intent of
0c8fdaac4. Internal code waits on_switchingUsersPromise, which settles with the login op, so these paths now wait through the login's retries too: SessionManager's handlers and the push grant (updatePushSubscriptionModelWithRawSubscription).The cap covers only a missing response. A server that keeps returning 5xx still holds waiters, as it does on main. The ops stay queued and persisted either way.
login(). That rejection also tells the app its token was bad. A follow-up could split the promise: internal code waits on the first outcome, andlogin()on the final one.Size (gzip -9 bytes, against #1577)
Systems Affected
Validation
Tests
Info
OP_REPO_MAX_WAITER_RETRIESfailures with no response, the waiter rejects and the op stays queued.addEmailduring the backoff after a failed login still sends one user create with the email, andlogin()resolves.vp check, fullvp test(1113), andbuild:prod(size limits) pass.Not tested in a browser.
Checklist
Programming Checklist
Interfaces:
Functions:
Typescript:
Other:
elem of arraysyntax. PreferforEachor usemapcontextif possible. Instead, we can pass it to function/constructor so that we don't callOneSignal.contextScreenshots
Checklist
Related Tickets
🤖 Generated with Claude Code