Skip to content

fix(auth): PKCE 교환 중 timeout이 이기면 받은 콜백 응답을 끝낸다 (AGT-4901) - #918

Open
unohee wants to merge 1 commit into
mainfrom
heewonoh/agt-4901-pkce-cancel-response
Open

unohee wants to merge 1 commit into
mainfrom
heewonoh/agt-4901-pkce-cancel-response

Conversation

@unohee

@unohee unohee commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

무엇

  • src/auth/pkceSettlement.ts에 endSupersededCallback(res)를 추가했습니다. settlement를 잃은 콜백 응답을 410 + Connection: close + 짧은 안내 HTML로 정확히 한 번 끝냅니다(이미 끝난 응답은 건드리지 않음).
  • oauthPkce.ts의 if (!settlement.finish()) return; 두 곳(성공·실패 경로)을 이 헬퍼로 바꿨습니다. 같은 패턴이 있던 linearPkce.ts, openrouterPkce.ts에도 똑같이 적용했습니다.
  • 테스트용으로 OAuthFlowOptions.timeoutMs(기본 120초 유지)를 추가했습니다.

왜

AGT-4901 (AGT-3443 잔여). 토큰 교환 도중 timeout·서버 오류가 먼저 settle하면, 이미 claim한 콜백의 res가 응답 없이 남아 브라우저가 계속 로딩하고 소켓이 열린 채로 있었습니다.

검증

  • npx vitest run src/auth/ → 7 files, 59 tests 통과.
  • 새 oauthPkce.flow.test.ts: 실제 loopback 서버에 콜백을 보내고 fetch를 abort될 때까지 매달아 둔 상태에서 timeout이 이기면 410으로 응답이 끝나는지, 성공(200, accountId 파싱)·교환 실패(500) 경로가 각각 한 번 응답하는지 확인.
  • 수정을 되돌리면 timeout 테스트가 응답을 못 받고 시간 초과로 실패하는 것을 확인했습니다(mutation check).
  • npm run typecheck 통과, oxlint src/auth/ 0 warnings.

…e exchange race (AGT-4901)

The callback handler returned without answering when the login timeout or a
server error settled the flow during the token exchange, leaving the browser
loading and the socket open. A shared endSupersededCallback now answers 410
with Connection: close exactly once. Applied to the OpenAI, Linear and
OpenRouter PKCE flows, which had the same two returns.
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