Skip to content

fix: oauth token race in http_transport#1269

Merged
burmudar merged 1 commit intomainfrom
wb/fix-race
Mar 9, 2026
Merged

fix: oauth token race in http_transport#1269
burmudar merged 1 commit intomainfrom
wb/fix-race

Conversation

@burmudar
Copy link
Contributor

@burmudar burmudar commented Mar 9, 2026

Fix a read race mentioned here by @keegancsmith

Test plan

Unit tests

@burmudar burmudar requested review from a team and keegancsmith March 9, 2026 13:41
@burmudar burmudar self-assigned this Mar 9, 2026
@burmudar burmudar merged commit 8711473 into main Mar 9, 2026
8 checks passed
@burmudar burmudar deleted the wb/fix-race branch March 9, 2026 13:48
Comment on lines 32 to +35
if err := t.refreshToken(ctx); err != nil {
return nil, err
}
token := t.getToken()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very minor: you lock in refresh and in getToken, and this is the only place you call both. Maybe instead you can refactor it to read like this

Suggested change
if err := t.refreshToken(ctx); err != nil {
return nil, err
}
token := t.getToken()
token, err := t.getToken(ctx)
if err != nil {
return nil, err
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I tend to agree. It did feel bit 💩 to do it - only thing that stopped me was getToken does more than what it says, although it's minor in the long run.

I'll update it in a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants