Skip to content

Share in-flight Azure token requests and run az CLI asynchronously - #1298

Merged
theoephraim merged 1 commit into
mainfrom
azure-dedupe-token-requests
Nov 12, 2026
Merged

theoephraim merged 1 commit into
mainfrom
azure-dedupe-token-requests

Conversation

@theoephraim

Copy link
Copy Markdown
Member

Fixes #1275.

When several secrets resolve at once with no cached token, each lookup ran its own token acquisition. With the Azure CLI fallback that meant one blocking execSync('az account get-access-token ...') per secret, which stalled the event loop long enough for other Key Vault requests to hit their 10s timeout.

  • getAccessToken now shares one in-flight request per resource. The entry is cleared on success and failure, so expiry checks and retries still work.
  • az runs through async spawnAsync (with a shell on Windows, where az is a .cmd shim), so a slow CLI no longer blocks other requests.
  • The CLI token cache files are read from AZURE_CONFIG_DIR when set, matching where az writes them.

Tests: three concurrent secrets with a service principal make one token request; with a fake az on PATH and an empty config dir, az is called exactly once.

Cross-process token caching (#1047) is left for later.

Concurrent secret lookups now share one token request per resource, so the az CLI fallback runs once instead of once per secret. az runs via async spawn so it no longer blocks the event loop and times out other Key Vault requests. The CLI token cache is read from AZURE_CONFIG_DIR when set.

Fixes #1275
@github-actions

Copy link
Copy Markdown
Contributor

bumpy-frog

The changes in this PR will be included in the next version bump.

patch Patch releases

  • @varlock/azure-key-vault-plugin 1.3.1 → 1.3.2

Bump files in this PR

Click here if you want to add another bump file to this PR


This comment is maintained by bumpy.

@pkg-pr-new

pkg-pr-new Bot commented Nov 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/varlock@1298
npm i https://pkg.pr.new/@varlock/azure-key-vault-plugin@1298

commit: a212096

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes: Reviewed token-request sharing, asynchronous Azure CLI execution, and the related tests and documentation.

  • Token sharing: Concurrent lookups share an instance-local request per resource, with cleanup on success and failure.
  • CLI fallback: az runs asynchronously with the existing timeout and tenant scoping, using a shell on Windows.
  • Config directory: Token-cache reads honor AZURE_CONFIG_DIR, with documentation updated accordingly.
  • Regression coverage: New tests verify one token acquisition for concurrent secrets. The plugin build, all 21 tests, and typecheck passed on Linux; Windows execution was not tested locally.

Pullfrog  | View workflow run | Using gpt-6.1-sol | 𝕏

@theoephraim
theoephraim merged commit 4f37eb5 into main Nov 12, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: azure-key-vault-plugin runs az account get-access-token once per secret, and the blocking calls time out Key Vault requests

1 participant