fix(providers): enable graceful termination during SSO browser authentication#151
Open
fix(providers): enable graceful termination during SSO browser authentication#151
Conversation
Fixes race condition in date-based log rotation that caused crashes when Claude sessions crossed midnight. The async rotation fired but writeToLogFile continued to write to the stream being closed, causing stream write-after-end errors. Changes: - Add defensive checks in writeToLogFile() to skip writes during rotation - Check isRotating flag and stream.writable property before writing - Enhance close() method to wait for in-progress rotation (max 5 seconds) - Add detailed comments explaining the race condition scenario Impact: Prevents application crashes in long-running sessions that span midnight. Trade-off: May skip 1-2 log entries during rotation (acceptable vs crash). Generated with AI Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
…tication Fixes issue where SSO authentication flow cannot be interrupted when waiting for browser callback, requiring manual process termination. Changes: - Add AbortController for cancellation support - Register SIGINT/SIGTERM handlers for graceful shutdown - Replace recursive polling with setInterval in waitForCallback - Enhance cleanup() to force-close server connections - Add proper error handling for user cancellation Pattern follows agent.ts signal handling implementation for consistency across the codebase. Generated with AI Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
TarasSpashchenko
approved these changes
Feb 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes issue where SSO authentication flow cannot be interrupted with Ctrl+C when waiting for browser callback. Previously, the process would hang indefinitely, requiring manual termination (kill -9).
Changes
agent.ts:486-496for consistent signal handling across the codebasewaitForCallbackwith non-recursivesetIntervalto prevent uninterruptible wait loopscloseAllConnections()Impact
Before:
After:
Checklist