Prevent potential duplicate calls to CreateDevice#6023
Merged
VelikovPetar merged 3 commits intodevelopfrom Nov 28, 2025
Merged
Conversation
Contributor
SDK Size Comparison 📏
|
andremion
reviewed
Nov 28, 2025
Contributor
andremion
left a comment
There was a problem hiding this comment.
I can't reproduce the issue even on develop
I deleted the token, then background, then foreground, but found one request POST https://chat.stream-io-api.com/devices
andremion
approved these changes
Nov 28, 2025
|
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.


🎯 Goal
We still have reports of the
CreateDeviceendpoint hitting rate limits. In this PR we introduce another level of guarding against duplicate calls, by introducing a local tracking of the device registered in the current session, plus a locking mechanism.🛠 Implementation details
CreateDevice/DeleteDeviceendpoints will fail if called without a connected user) to support the case where different users a switched in the sameChatClientPushTokenUpdateHandler#addDevice: check if the same token was registered previously in the current session (in addition to the check againsuser.devices)CreateDeviceinvocations at the same timeDeviceApiandChatApiby removing unnecessary parameters🎨 UI Changes
NA
🧪 Testing
Pretty difficult to test in a real-world scenario. One possible scenario to test is to manually delete the firebase token:
FirebaseMessaging.getInstance().deleteToken()Then put the app in background, and then back to foreground. There should be two attempts to register the new token:
onNewTokenBut only one
CreateDeviceshould be fired.Another possibility is to simulate repeated calls to
FirebaseMessagingDelegate.registerPushDevice- again, only oneCreateDeviceshould be fired.