Skip to content

fix(gitlab): recover after token refresh failure - #1

Open
jackspiece wants to merge 1 commit into
portfolio/decap-refresh-basefrom
portfolio/gitlab-refresh-failure-recovery
Open

jackspiece wants to merge 1 commit into
portfolio/decap-refresh-basefrom
portfolio/gitlab-refresh-failure-recovery

Conversation

@jackspiece

@jackspiece jackspiece commented Oct 4, 2026 •

Copy link
Copy Markdown
Owner

Summary

The GitLab backend clears refreshedTokenPromise only after a successful refresh. If the refresh rejects, that rejected promise remains cached. Later refresh attempts, token readers, and API requests can keep receiving the same rejection without trying the token endpoint again.

Move cleanup into finally so concurrent callers still share one in-flight refresh, while a later request can recover after a temporary failure. The original rejection is preserved, and credentials are updated only on success.

Regression coverage

  • Concurrent refresh callers and token readers share the same pending promise.
  • A successful refresh permits a later refresh using the rotated refresh token.
  • Concurrent callers receive the original failure without changing stored credentials, then a later refresh can succeed.
  • A request recovers after an OAuth endpoint returns a mocked HTTP 503, using the real PKCE authenticator and mocked GitLab HTTP endpoints.

Before the production fix, the concurrency-success control passed and both recovery regressions failed. All three pass with the fix.

Verification

  • Full pnpm run test:ci --runInBand: lint, formatting, TypeScript, four Cypress-runner unit checks, and Jest passed.
  • Jest: 119 suites passed, 2 skipped; 1,498 tests passed, 1,304 skipped; 138 snapshots passed.
  • GitLab backend and PKCE suites: 82 tests and 2 snapshots passed.
  • pnpm --filter decap-cms-backend-gitlab run build:esm: 6 files compiled.
  • Independent review reran the GitLab backend test file: 30 tests and 2 snapshots passed.
  • git diff --check passed.

Tested locally with Node 24.19.0 and pnpm 11.12.0. Cypress-runner unit checks do not launch browser E2E tests.

Remote CI on commit 570a9170b79d9e180a3e4d7a83e1e07b3837aca5 passed all four build-unit jobs: Ubuntu with Node 22 and 24, macOS with Node 24, and Windows with Node 24. Workflow run.

The E2E build is queued waiting for the workflow's depot-ubuntu-24.04 runner label, with no runner assigned at the latest check. Browser E2E and live GitLab remain unverified.

Review base

This pull request is ready for review in this fork. Merge remains blocked until the exact-head browser E2E gate completes. The base branch is pinned to upstream commit 1d5868347d3d8648d7d5f7f59fc1b46595881b29, so the diff contains only the two changed GitLab files. The fork's main branch is unchanged. This has not been submitted upstream or released.

@jackspiece
jackspiece marked this pull request as ready for review October 4, 2026 16:04
@chatgpt-codex-connector

This comment has been minimized.

@hacktron-app

This comment has been minimized.

@chatgpt-codex-connector

This comment has been minimized.

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.

1 participant