Skip to content

Token refresh doesn't work in traffic storm #1193

Closed
@inlined

Description

@inlined

This is a reassignment to close out firebase/firebase-functions#579. The customer's function makes many many Admin SDK API calls every 15 minutes. Previously it would crash with 401 errors because the API server was no longer recognizing the token as valid. The customer was able to work around this error by calling admin.app().INTERNAL.getToken(/*force_refresh=*/true) before their code ran, so it's definitely an Admin bug.

Given the frequency of the crashes, I expect that this bug is happening on the border of when a token is about to expire and the Admin SDK isn't properly refreshing it. I have two theories for what could cause this:

  1. There may be a bug in the code that actually refreshes the tokens. For example, here is a bug where a token that is supposed to expire from [1m, 2m) will never get refreshed.
  2. This may be an issue where the network pool for the auth token is full of serialized requests and it takes longer to flush than the token is valid for.

My recommendation would probably be something surgical like changing this line to subtract a few minutes from the actual expiration time so that we don't serialize requests with a token that's about to expire.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions