Skip to content

Harden GitHub auth context and cancel abandoned requests#71

Merged
stylessh merged 1 commit intomainfrom
stylessh/fix-private-repo-crash
Apr 11, 2026
Merged

Harden GitHub auth context and cancel abandoned requests#71
stylessh merged 1 commit intomainfrom
stylessh/fix-private-repo-crash

Conversation

@stylessh
Copy link
Copy Markdown
Owner

Summary

  • Catches uncaught token refresh errors in getGitHubAppUserInstallations and getGitHubUserContextForOwner so a failed refresh gracefully falls back to the OAuth client instead of crashing the Worker
  • Eagerly verifies installation auth in getGitHubContextForOwner@octokit/auth-app authenticates lazily so the existing try/catch could never catch auth failures on private repos
  • Skips suspended GitHub App installations in findGitHubAppInstallationForOwner
  • Caches resolved GitHub contexts per-request via WeakMap<Request> so parallel server functions within a single request reuse one session/installation lookup instead of creating a new client per query
  • Propagates the incoming HTTP request's abort signal to GitHub API calls via AbortSignal.any so navigating away cancels in-flight work instead of letting abandoned requests hang the Worker
  • Adds debug() logging throughout the auth and context resolution flow for visibility

Test plan

  • Access PR/issue/review detail pages for private repos — should load without Worker crash
  • Rapidly switch between tabs using keyboard shortcuts — should no longer trigger "Worker hung" errors
  • Verify debug logs appear in dev showing token resolution and context caching
  • Confirm write operations (merge, review, branch delete) still work with user token

- Catch uncaught token refresh errors in getGitHubAppUserInstallations
  and getGitHubUserContextForOwner so a failed refresh falls back to the
  OAuth client instead of crashing the Worker
- Eagerly verify installation auth in getGitHubContextForOwner since
  @octokit/auth-app authenticates lazily and the existing try/catch
  could never catch auth failures
- Skip suspended GitHub App installations
- Cache resolved GitHub contexts per-request (WeakMap<Request>) so
  parallel server functions reuse one session/installation lookup
- Propagate the incoming HTTP request abort signal to GitHub API calls
  via AbortSignal.any so navigating away cancels in-flight work
- Add debug() logging to the auth and context resolution flow
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
diffkit 7fb0a0e Commit Preview URL

Branch Preview URL
Apr 11 2026, 09:50 PM

@stylessh stylessh merged commit 0e1084f into main Apr 11, 2026
4 checks passed
stylessh added a commit that referenced this pull request Apr 18, 2026
- Catch uncaught token refresh errors in getGitHubAppUserInstallations
  and getGitHubUserContextForOwner so a failed refresh falls back to the
  OAuth client instead of crashing the Worker
- Eagerly verify installation auth in getGitHubContextForOwner since
  @octokit/auth-app authenticates lazily and the existing try/catch
  could never catch auth failures
- Skip suspended GitHub App installations
- Cache resolved GitHub contexts per-request (WeakMap<Request>) so
  parallel server functions reuse one session/installation lookup
- Propagate the incoming HTTP request abort signal to GitHub API calls
  via AbortSignal.any so navigating away cancels in-flight work
- Add debug() logging to the auth and context resolution flow
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