Skip to content

fix(chatgptauth): drain OAuth callback responses before closing - #1996

Merged
lizhengfeng101 merged 1 commit into
mainfrom
fix/oauth-callback-response
Nov 18, 2026
Merged

lizhengfeng101 merged 1 commit into
mainfrom
fix/oauth-callback-response

Conversation

@lizhengfeng101

Copy link
Copy Markdown
Contributor

Fixes #1952.

The login attempt can finish while the loopback server is still writing the browser's callback response. Closing the server immediately can leave the CLI signed in while the browser reports a connection error.

Give active responses up to one second to finish, using a shutdown context independent of the login context. Force-close remaining connections if graceful shutdown fails. Cleanup does not change the login result or wait for the browser opener to exit.

Verification

  • Added a channel-synchronized loopback test for successful authorization, denial, token exchange failure, canceled login, and a stalled response. Restoring immediate close makes all five cases fail.
  • The new regression and the existing browser-opener lifetime test both passed in 10 consecutive runs with the race detector.
  • make test PACKAGES=./internal/chatgptauth, make test, make check, and make coverage passed. Overall coverage: 91.8%.

AI disclosure: OpenAI Codex (gpt-6.2-astra) assisted with implementation, tests, and PR preparation. OpenCodeReview (gpt-6.2-astra) ran the pre-commit review.

@github-actions

Copy link
Copy Markdown
Contributor

✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s).

@lizhengfeng101
lizhengfeng101 merged commit 5d6552a into main Nov 18, 2026
13 checks passed
@lizhengfeng101
lizhengfeng101 deleted the fix/oauth-callback-response branch November 18, 2026 13:42
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.

bug(chatgptauth): gracefully shut down the OAuth callback server

2 participants