The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 22:15 UTC
fix(codex): keep the launcher error that precedes an exit summary (#33290)
Co-authored-by: Codex (gpt-6.1-sol) <noreply@openai.com>
Timur Sharifianov committed
Nov 12, 2026 at 00:12 UTC
7e796802aa849a89b4dcc70d19e12cf5d7ec38f8
2 files changed
+56
-4
packages/effect-codex-app-server/src/_internal/stdio.test.ts
+39
@@ -166,6 +166,45 @@ describe("Codex App Server stderr excerpt", () => {
166
stderr: "WARNING: proceeding without PATH aliases\nMissing OpenAI API key.\n",
167
excerpt: "Missing OpenAI API key.",
168
},
169
+ {
170
+ name: "launcher exit summary after a DNS failure",
171
+ stderr: [
172
+ "Starting provider",
173
+ 'проверить токен LLM: Get "https://llm-gateway.example/api/models": dial tcp: lookup llm-gateway.example: no such host',
174
+ "не удалось отправить метрики на сервер: no such host",
175
+ "Ошибка: ошибка запуска плагина: exit status 1",
176
+ ].join("\n"),
177
+ excerpt:
178
+ 'проверить токен LLM: Get "https://llm-gateway.example/api/models": dial tcp: lookup llm-gateway.example: no such host | не удалось отправить метрики на сервер: no such host | Ошибка: ошибка запуска плагина: exit status 1',
179
+ },
180
+ {
181
+ name: "labelled launcher exit summary after an authentication failure",
182
+ stderr: [
183
+ 'oauth2: "invalid_request" "Errors.OIDCSession.RefreshTokenInvalid"',
184
+ "Error: provider launcher exited with code 1.",
185
+ ].join("\n"),
186
+ excerpt:
187
+ 'oauth2: "invalid_request" "Errors.OIDCSession.RefreshTokenInvalid" | Error: provider launcher exited with code 1.',
188
+ },
189
+ {
190
+ name: "final launcher summary takes precedence over an earlier error label",
191
+ stderr: [
192
+ "Error: starting provider",
193
+ "lookup failed: no such host",
194
+ "Ошибка: exit status 1",
195
+ ].join("\n"),
196
+ excerpt: "Error: starting provider | lookup failed: no such host | Ошибка: exit status 1",
197
+ },
198
+ {
199
+ name: "launcher summary alone",
200
+ stderr: "Error: command failed with exit code 1\n",
201
+ excerpt: "Error: command failed with exit code 1",
202
+ },
203
+ {
204
+ name: "launcher diagnostics remain bounded",
205
+ stderr: `${"x".repeat(1_000)}\noauth2: invalid_request\nError: launcher exited with code 1\n`,
206
+ excerpt: `…${`${"x".repeat(1_000)} | oauth2: invalid_request | Error: launcher exited with code 1`.slice(-511)}`,
207
+ },
208
{
209
name: "ANSI color, carriage returns and repeated whitespace",
210
stderr: "\u001b[31m Error:\t config.toml is invalid \u001b[0m\r\n",
packages/effect-codex-app-server/src/_internal/stdio.ts
+17
-4
@@ -56,6 +56,7 @@ const STDERR_TAIL_MAX_CHARS = 8_192;
56
const STDERR_EXCERPT_MAX_CHARS = 512;
57
// `Error: …`, `TypeError: …`, `Error [ERR_MODULE_NOT_FOUND]: …`, `error: …`, `ERROR: …`, `fatal: …`
58
const ERROR_LINE_PATTERN = /^(?:[a-z]*error|fatal)(?: ?\[[^\]]+\])?:\s*\S/i;
59
+const EXIT_SUMMARY_PATTERN = /\b(?:exit status|exit code|exited with code)\s+\d+\.?$/i;
60
61
export const appendStderrTail = (current: string, chunk: string): string => {
62
const next = `${current}${chunk}`;
@@ -68,13 +69,25 @@ export const stderrExcerpt = (tail: string): string | undefined => {
69
.split(/\r?\n/)
70
.map((line) => line.trim().replace(/\s+/g, " "))
71
.filter((line) => line.length > 0);
71
- const line = lines.findLast((candidate) => ERROR_LINE_PATTERN.test(candidate)) ?? lines.at(-1);
72
+ const errorIndex = lines.findLastIndex((candidate) => ERROR_LINE_PATTERN.test(candidate));
73
+ const lineIndex =
74
+ errorIndex === -1 || EXIT_SUMMARY_PATTERN.test(lines.at(-1) ?? "")
75
+ ? lines.length - 1
76
+ : errorIndex;
77
+ const line = lines[lineIndex];
78
if (line === undefined) {
79
return undefined;
80
}
75
- return line.length <= STDERR_EXCERPT_MAX_CHARS
76
- ? line
77
- : `${line.slice(0, STDERR_EXCERPT_MAX_CHARS - 1)}…`;
81
+ // Wrappers can print the actual failure before their generic exit-status summary.
82
+ const excerpt = EXIT_SUMMARY_PATTERN.test(line)
83
+ ? lines.slice(Math.max(0, lineIndex - 2), lineIndex + 1).join(" | ")
84
+ : line;
85
+ if (excerpt.length <= STDERR_EXCERPT_MAX_CHARS) {
86
+ return excerpt;
87
+ }
88
+ return excerpt !== line
89
+ ? `…${excerpt.slice(-(STDERR_EXCERPT_MAX_CHARS - 1))}`
90
+ : `${excerpt.slice(0, STDERR_EXCERPT_MAX_CHARS - 1)}…`;
91
};
92
93
export const makeStderrTail = Effect.fn("makeStderrTail")(function* (