mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-28 11:41:04 +00:00
Add global uncaught exception handler to suppress known race condition in @lydell/node-pty where a deferred resize fires after the pty process has already exited on Windows. Tracking bug: https://github.com/microsoft/node-pty/issues/827 Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/**
|
|
* @license
|
|
* Copyright 2025 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import './src/gemini.js';
|
|
import { main } from './src/gemini.js';
|
|
import { FatalError } from '@qwen-code/qwen-code-core';
|
|
import { writeStderrLine } from './src/utils/stdioHelpers.js';
|
|
|
|
// --- Global Entry Point ---
|
|
|
|
// Suppress known race condition in @lydell/node-pty on Windows where a
|
|
// deferred resize fires after the pty process has already exited.
|
|
// Tracking bug: https://github.com/microsoft/node-pty/issues/827
|
|
process.on('uncaughtException', (error) => {
|
|
if (
|
|
process.platform === 'win32' &&
|
|
error instanceof Error &&
|
|
error.message === 'Cannot resize a pty that has already exited'
|
|
) {
|
|
return;
|
|
}
|
|
|
|
if (error instanceof Error) {
|
|
writeStderrLine(error.stack ?? error.message);
|
|
} else {
|
|
writeStderrLine(String(error));
|
|
}
|
|
process.exit(1);
|
|
});
|
|
|
|
main().catch((error) => {
|
|
if (error instanceof FatalError) {
|
|
let errorMessage = error.message;
|
|
if (!process.env['NO_COLOR']) {
|
|
errorMessage = `\x1b[31m${errorMessage}\x1b[0m`;
|
|
}
|
|
console.error(errorMessage);
|
|
process.exit(error.exitCode);
|
|
}
|
|
console.error('An unexpected critical error occurred:');
|
|
if (error instanceof Error) {
|
|
console.error(error.stack);
|
|
} else {
|
|
console.error(String(error));
|
|
}
|
|
process.exit(1);
|
|
});
|