Skip to content

feat: add timeout to SMD token refresh and benchmark - #130

Merged
synackd merged 3 commits into
mainfrom
pr/b-token-refresh-timeout
Sep 8, 2026
Merged

synackd merged 3 commits into
mainfrom
pr/b-token-refresh-timeout

Conversation

@synackd

@synackd synackd commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Description

Introduces a 10‑second timeout for SMD token refresh operations to prevent potential deadlocks when the OIDC token endpoint is slow or unresponsive. A new constant defaultRefreshTimeout is defined and used with context.WithTimeout in both RefreshToken and refreshTokenIfCurrent. A refreshLock mutex is added to serialize concurrent refresh attempts, ensuring only one refresh request proceeds at a time. Additionally, a benchmark BenchmarkRefreshToken (in smdclient_benchmark_test.go) measures the latency of the refresh path. Comprehensive tests have been added to verify correct behavior under concurrent requests. These changes improve robustness of the SMD client during token expiration handling.

Fixes #128 (comment)

Checklist

  • My code follows the style guidelines of this project
  • I have added/updated comments where needed
  • I have added tests that prove my fix is effective or my feature works
  • I have run make test (or equivalent) locally and all tests pass
  • I have updated the relevant documentation (CLI examples, man pages, README, other docs, etc.)
  • DCO Sign-off: All commits are signed off (git commit -s) with my real name and email
  • REUSE Compliance:
    • Each new/modified source file has SPDX copyright and license headers
    • Any non-commentable files include a <filename>.license sidecar
    • All referenced licenses are present in the LICENSES/ directory

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Dependency update
  • Build system/CI

@synackd
synackd force-pushed the pr/b-token-refresh-timeout branch 3 times, most recently from ba43b84 to 206a36f Compare August 31, 2026 16:31
@synackd synackd mentioned this pull request Aug 31, 2026
11 of 15 tasks
@synackd
synackd marked this pull request as ready for review August 31, 2026 16:44
Comment thread internal/smdclient/oidc.go Outdated
Comment thread internal/smdclient/oidc.go
Comment thread internal/smdclient/oidc.go Outdated
@synackd
synackd force-pushed the pr/b-token-refresh-timeout branch from fe17047 to 079cac4 Compare September 2, 2026 16:42
Introduce a 10‑second timeout for SMD token refresh operations to
prevent potential deadlocks when the OIDC token endpoint is slow or
unresponsive. A new constant defaultRefreshTimeout is defined and used
with context.WithTimeout in both RefreshToken and refreshTokenIfCurrent.
A refreshLock mutex is added to serialize concurrent refresh attempts,
ensuring only one refresh request proceeds at a time.  Additionally, a
benchmark BenchmarkRefreshToken (in smdclient_benchmark_test.go)
measures the latency of the refresh path. Comprehensive tests have been
added to verify correct behavior under concurrent requests. These
changes improve robustness of the SMD client during token expiration
handling.

Signed-off-by: Devon Bautista <17506592+synackd@users.noreply.github.com>
Signed-off-by: Devon Bautista <17506592+synackd@users.noreply.github.com>
Signed-off-by: Devon Bautista <17506592+synackd@users.noreply.github.com>
@synackd
synackd force-pushed the pr/b-token-refresh-timeout branch from 079cac4 to 97a8cd2 Compare September 2, 2026 20:19
@synackd
synackd enabled auto-merge (squash) September 8, 2026 15:23
@synackd
synackd merged commit 5db5cbc into main Sep 8, 2026
14 checks passed
@synackd
synackd deleted the pr/b-token-refresh-timeout branch September 8, 2026 15:57
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.

2 participants