mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
Merge branch 'main' into fix-kimi2-token-limits
This commit is contained in:
@@ -1227,4 +1227,28 @@ describe('FileCommandLoader', () => {
|
|||||||
expect(commands).toHaveLength(0);
|
expect(commands).toHaveLength(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('AbortError handling', () => {
|
||||||
|
it('should silently ignore AbortError when operation is cancelled', async () => {
|
||||||
|
const userCommandsDir = Storage.getUserCommandsDir();
|
||||||
|
mock({
|
||||||
|
[userCommandsDir]: {
|
||||||
|
'test1.toml': 'prompt = "Prompt 1"',
|
||||||
|
'test2.toml': 'prompt = "Prompt 2"',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const loader = new FileCommandLoader(null);
|
||||||
|
const controller = new AbortController();
|
||||||
|
const signal = controller.signal;
|
||||||
|
|
||||||
|
// Start loading and immediately abort
|
||||||
|
const loadPromise = loader.loadCommands(signal);
|
||||||
|
controller.abort();
|
||||||
|
|
||||||
|
// Should not throw or print errors
|
||||||
|
const commands = await loadPromise;
|
||||||
|
expect(commands).toHaveLength(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -120,7 +120,11 @@ export class FileCommandLoader implements ICommandLoader {
|
|||||||
// Add all commands without deduplication
|
// Add all commands without deduplication
|
||||||
allCommands.push(...commands);
|
allCommands.push(...commands);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {
|
// Ignore ENOENT (directory doesn't exist) and AbortError (operation was cancelled)
|
||||||
|
const isEnoent = (error as NodeJS.ErrnoException).code === 'ENOENT';
|
||||||
|
const isAbortError =
|
||||||
|
error instanceof Error && error.name === 'AbortError';
|
||||||
|
if (!isEnoent && !isAbortError) {
|
||||||
console.error(
|
console.error(
|
||||||
`[FileCommandLoader] Error loading commands from ${dirInfo.path}:`,
|
`[FileCommandLoader] Error loading commands from ${dirInfo.path}:`,
|
||||||
error,
|
error,
|
||||||
|
|||||||
@@ -69,7 +69,14 @@ if (process.env.DEBUG) {
|
|||||||
// than the relaunched process making it harder to debug.
|
// than the relaunched process making it harder to debug.
|
||||||
env.GEMINI_CLI_NO_RELAUNCH = 'true';
|
env.GEMINI_CLI_NO_RELAUNCH = 'true';
|
||||||
}
|
}
|
||||||
const child = spawn('node', nodeArgs, { stdio: 'inherit', env });
|
// Use process.cwd() to inherit the working directory from launch.json cwd setting
|
||||||
|
// This allows debugging from a specific directory (e.g., .todo)
|
||||||
|
const workingDir = process.env.QWEN_WORKING_DIR || process.cwd();
|
||||||
|
const child = spawn('node', nodeArgs, {
|
||||||
|
stdio: 'inherit',
|
||||||
|
env,
|
||||||
|
cwd: workingDir,
|
||||||
|
});
|
||||||
|
|
||||||
child.on('close', (code) => {
|
child.on('close', (code) => {
|
||||||
process.exit(code);
|
process.exit(code);
|
||||||
|
|||||||
Reference in New Issue
Block a user