Skip to content

[FR] Optimize Token Retrieval for Messaging#sendEach to Reduce Unnecessary Fetch Requests #2645

@bombard1004

Description

@bombard1004

Is your feature request related to a problem? Please describe.
Messaging#sendEach makes an HTTP request for each message. The problem is that it attempts to retrieve a token for each request. Although the tokens are cached internally, the requests are processed concurrently, so the cached value cannot be used, leading to a burst of unnecessary token fetch requests.

Describe the solution you'd like
Instead of attempting to retrieve a token for each request, a token should be obtained before sending the requests and then injected into each send request.

Describe alternatives you've considered

Additional context
Add a token: string parameter to FirebaseMessagingRequestHandler#invokeHttp2RequestHandlerForSendResponse and include it when creating the request object.
Inside AuthorizedHttp2Client#send, remove the getToken call and instead find and add the token from the request object passed as a parameter.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions