fix(cli): suppress unhandled AbortError logs during request cancellation (#22621)

This commit is contained in:
euxaristia
2026-04-09 14:27:08 -04:00
committed by GitHub
parent e029f1029b
commit 85f4d53c91
2 changed files with 27 additions and 0 deletions
+8
View File
@@ -164,6 +164,14 @@ export function getNodeMemoryArgs(isDebugMode: boolean): string[] {
export function setupUnhandledRejectionHandler() {
let unhandledRejectionOccurred = false;
process.on('unhandledRejection', (reason, _promise) => {
// AbortError is expected when the user cancels a request (e.g. pressing ESC).
// It may surface as an unhandled rejection due to async timing in the
// streaming pipeline, but it is not a bug.
if (reason instanceof Error && reason.name === 'AbortError') {
debugLogger.log(`Suppressed unhandled AbortError: ${reason.message}`);
return;
}
const errorMessage = `=========================================
This is an unexpected error. Please file a bug report using the /bug tool.
CRITICAL: Unhandled Promise Rejection!