Skip to content

[server] guard token renewals against races #9526

@AlexTugarev

Description

@AlexTugarev

While working on #9524, I've noticed an issue the token service in the server component.

Multiple API requests are raced to fetch data as quick as possible when the context parsing machinery is running during workspace creation/start. The token service is inquired for each API request separately. And here comes the problem: the renewal process is triggered internally in the token service, but this is not an atomic operation, it rather is rescheduled to the next tick. This ends up in multiple token renewal requests.

While we've seen no evidence for issues with bitbucket.org, it seems to be broken for Bitbucket Servers, because the repeated token renewal for the same refresh_token is declined.

Proposed solution would be to await on the same token renewal promise from the token service.

Metadata

Metadata

Assignees

No one assigned

    Labels

    meta: staleThis issue/PR is stale and will be closed soonteam: webappIssue belongs to the WebApp teamtype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions