Subscriber: final response in "terminated", unsubscribe on UA.stop() - #978
Open
neutrino38 wants to merge 1 commit into
Open
neutrino38 wants to merge 1 commit into
neutrino38 wants to merge 1 commit into
Conversation
- The `terminated` event gets the final response as a 4th argument. SUBSCRIBE_NON_OK_RESPONSE covers 404 and 489 alike, which call for different reactions (retry later vs. the server has no such event package). - An invalid target throws TypeError in the constructor, as UA.sendMessage() does, instead of sending `SUBSCRIBE undefined`. - terminate() cancels the pending refresh, and the 2xx to the un-SUBSCRIBE no longer schedules a new one (it used to re-SUBSCRIBE after Expires: 0 when the final NOTIFY was lost). If no final NOTIFY comes within 32 s, the subscription ends with UNSUBSCRIBE_TIMEOUT, a code that was declared but never emitted. - UA.stop() unsubscribes every subscription it knows of, as it terminates sessions, so that the server does not keep notifying a gone UA until the subscription expires. A stopped UA drops incoming requests, the final NOTIFY included: such a subscription ends on the 2xx to its un-SUBSCRIBE, with the new code UNSUBSCRIBED_ON_UA_STOP. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
terminatedgets the final response as a 4th argument:(code, reason, retryAfter, response). It is set forSUBSCRIBE_NON_OK_RESPONSE,SUBSCRIBE_AUTHENTICATION_FAILED,SUBSCRIBE_WRONG_OK_RESPONSEand the newUNSUBSCRIBED_ON_UA_STOP, andundefinedotherwise. Existing listeners are not affected.TypeError: Invalid target: …, asMessageandOptionsdo. The normalized URI is kept and reused for the initialSUBSCRIBE.
terminate():C.FINAL_NOTIFY_TIMEOUT_SEC(32 s, like Timer F), the subscription ends withUNSUBSCRIBE_TIMEOUT. That code was declared but neveremitted.
UA.stop()unsubscribes every subscription that has been sent. The UA tracks subscribers throughnewSubscriber()anddestroySubscriber(), as it does for sessions,and calls
terminate()on each one before closing. A stopped UA drops in Jump to bottom (ctrl+End) ↓ e final NOTIFY, so a subscriber in that situation ends on the 2xx to itsBehaviour changes
ua.subscribe()with an invalid target now throws from the constructor. Before, it sent a malformed request.UNSUBSCRIBED_ON_UA_STOP = 8.terminate()on every subscriber beforeua.stop()keep working:terminate()is idempotent.Known limitation
If
ua.stop()is called while an initial SUBSCRIBE is still waiting for its response, the un-SUBSCRIBE is queued (no dialog exists yet). It is only sent once the 2xx arrives,and by then the UA is closed. This is the same as before for
terminate()in that state. Fixing it would mean changingRequestSender's behaviour on a closed UA, which is outof scope here.