Skip to content

Retry authorization after refreshing a stored token#247

Merged
Schniz merged 4 commits into
mainfrom
schniz/retry-after-token-refresh
Jul 13, 2026
Merged

Retry authorization after refreshing a stored token#247
Schniz merged 4 commits into
mainfrom
schniz/retry-after-token-refresh

Conversation

@Schniz

@Schniz Schniz commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • detect when getVercelToken() replaces the stored access token
  • treat the replacement token as fresh so transient 401/403 responses are retried
  • extend the retry budget to cover delayed authorization propagation
  • recognize supported auth error shapes across package/bundle boundaries
  • add a regression test reproducing refresh followed by a transient 403

This was extracted from #246 after local traces showed a successful OAuth refresh followed by a transient Sandbox 403; the same stored token succeeded seconds later.

Testing

  • pnpm vitest --run test/args/auth.test.ts src/util/fresh-auth-retry.test.ts
  • pnpm typecheck

@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sandbox Ready Ready Preview, Comment, Open in v0 Jul 13, 2026 6:41pm
sandbox-cli Ready Ready Preview, Comment Jul 13, 2026 6:41pm
sandbox-sdk-ai-example Ready Ready Preview, Comment Jul 13, 2026 6:41pm
workflow-code-runner Ready Ready Preview, Comment Jul 13, 2026 6:41pm

Request Review

@Schniz
Schniz merged commit 917f3b7 into main Jul 13, 2026
12 checks passed
@Schniz
Schniz deleted the schniz/retry-after-token-refresh branch July 13, 2026 19:08
@github-actions github-actions Bot mentioned this pull request Jul 13, 2026
marc-vercel pushed a commit that referenced this pull request Jul 15, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## sandbox@3.4.3

### Patch Changes

- Retry transient authorization failures after refreshing a stored
access token. ([#247](#247))

- Updated dependencies
[[`871e8b71f9a33beb804524f46f176cfc861716c3`](871e8b7)]:
  - @vercel/sandbox@2.6.1
## @vercel/sandbox@2.6.1

### Patch Changes

- Expose a typed error when creating a sandbox user whose username
already exists. ([#250](#250))

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Abdul-Karim-Baisuev pushed a commit to Abdul-Karim-Baisuev/sandbox that referenced this pull request Jul 16, 2026
## Summary

- detect when `getVercelToken()` replaces the stored access token
- treat the replacement token as fresh so transient 401/403 responses
are retried
- extend the retry budget to cover delayed authorization propagation
- recognize supported auth error shapes across package/bundle boundaries
- add a regression test reproducing refresh followed by a transient 403

This was extracted from vercel#246 after local traces showed a successful
OAuth refresh followed by a transient Sandbox 403; the same stored token
succeeded seconds later.
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