-
Notifications
You must be signed in to change notification settings - Fork 2.5k
OpenAI-compatible server reliability improvements via HTTP/1.1 keep-alive config and error handling #404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
OpenAI-compatible server reliability improvements via HTTP/1.1 keep-alive config and error handling #404
Changes from all commits
466eed9
087d7b3
0886753
89cd276
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,13 +39,50 @@ import { | |
| IdeConnectionType, | ||
| } from '@qwen-code/qwen-code-core'; | ||
| import { validateAuthMethod } from './config/auth.js'; | ||
| import { getEffectiveAuthType } from './config/config.js'; | ||
| import { setMaxSizedBoxDebugging } from './ui/components/shared/MaxSizedBox.js'; | ||
| import { validateNonInteractiveAuth } from './validateNonInterActiveAuth.js'; | ||
| import { checkForUpdates } from './ui/utils/updateCheck.js'; | ||
| import { handleAutoUpdate } from './utils/handleAutoUpdate.js'; | ||
| import { appEvents, AppEvent } from './utils/events.js'; | ||
| import { SettingsContext } from './ui/contexts/SettingsContext.js'; | ||
|
|
||
| /** | ||
| * Initialize authentication for the config based on settings and environment. | ||
| * Centralizes auth initialization to follow DRY principle. | ||
| * @param config - The Config instance to initialize auth for | ||
| * @param settings - The loaded settings containing selectedAuthType | ||
| * @returns Promise<void> | ||
| */ | ||
| async function initializeAuth( | ||
| config: Config, | ||
| settings: LoadedSettings, | ||
| ): Promise<void> { | ||
| // Skip if using external auth | ||
| if (settings.merged.useExternalAuth) { | ||
| return; | ||
| } | ||
|
|
||
| // Get the effective auth type based on configuration hierarchy | ||
| const effectiveAuthType = getEffectiveAuthType(settings.merged); | ||
|
|
||
| if (!effectiveAuthType) { | ||
| return; | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Critical] — gpt-5.4 via Qwen Code /review |
||
|
|
||
| try { | ||
| const err = validateAuthMethod(effectiveAuthType); | ||
| if (!err) { | ||
| await config.refreshAuth(effectiveAuthType); | ||
| } | ||
| } catch (err) { | ||
| // Log auth errors but don't exit - let the appropriate handler deal with auth errors | ||
| if (config.getDebugMode()) { | ||
| console.error('Auth initialization error:', err); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| export function validateDnsResolutionOrder( | ||
| order: string | undefined, | ||
| ): DnsResolutionOrder { | ||
|
|
@@ -191,6 +228,12 @@ export async function main() { | |
|
|
||
| await config.initialize(); | ||
|
|
||
| // Initialize auth after config.initialize() to ensure correct backend is used | ||
| // In sandbox mode, auth is handled separately below to avoid OAuth redirect issues | ||
| if (!process.env.SANDBOX) { | ||
| await initializeAuth(config, settings); | ||
| } | ||
|
|
||
| if (config.getIdeMode() && config.getIdeModeFeature()) { | ||
| await config.getIdeClient().connect(); | ||
| logIdeConnection(config, new IdeConnectionEvent(IdeConnectionType.START)); | ||
|
|
@@ -214,21 +257,12 @@ export async function main() { | |
| : []; | ||
| const sandboxConfig = config.getSandbox(); | ||
| if (sandboxConfig) { | ||
| if ( | ||
| settings.merged.selectedAuthType && | ||
| !settings.merged.useExternalAuth | ||
| ) { | ||
| // Validate authentication here because the sandbox will interfere with the Oauth2 web redirect. | ||
| try { | ||
| const err = validateAuthMethod(settings.merged.selectedAuthType); | ||
| if (err) { | ||
| throw new Error(err); | ||
| } | ||
| await config.refreshAuth(settings.merged.selectedAuthType); | ||
| } catch (err) { | ||
| console.error('Error authenticating:', err); | ||
| process.exit(1); | ||
| } | ||
| // Initialize auth before entering sandbox to avoid OAuth redirect issues | ||
| try { | ||
| await initializeAuth(config, settings); | ||
| } catch (err) { | ||
| console.error('Error authenticating:', err); | ||
| process.exit(1); | ||
| } | ||
| await start_sandbox(sandboxConfig, memoryArgs, config); | ||
| process.exit(0); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Critical] This new shared auth resolver no longer considers
QWEN_OAUTH_TOKEN, even though other code paths still treat that env var as a valid signal for Qwen auth. As soon asvalidateNonInteractiveAuth()switches to this helper, existing token-based Qwen setups stop resolving an auth type in non-interactive/shared flows. Please preserve the previous env-based auth matrix here before making this the source of truth.— gpt-5.4 via Qwen Code /review