chore: add temporary P2 child debug channel for acceptance diagnosis

This commit is contained in:
2026-08-11 19:26:57 +02:00
parent e3dd5897f8
commit f6c2e6fc40
3 changed files with 17 additions and 3 deletions
+1
View File
@@ -776,6 +776,7 @@ async function writeInstallationFiles(ctx) {
}, },
"workspace-maintenance": { "workspace-maintenance": {
image: ctx.coreImageTag, image: ctx.coreImageTag,
environment: { P2_CHILD_DEBUG: "1" },
extra_hosts: ["host.docker.internal:host-gateway"], extra_hosts: ["host.docker.internal:host-gateway"],
}, },
qdrant: { qdrant: {
+9 -2
View File
@@ -249,8 +249,15 @@ function createProductionService(): WorkspacePreprocessingService {
let stderr = ""; let stderr = "";
child.stdout?.on("data", (chunk: Buffer) => { stdout += chunk.toString("utf8"); }); child.stdout?.on("data", (chunk: Buffer) => { stdout += chunk.toString("utf8"); });
child.stderr?.on("data", (chunk: Buffer) => { stderr += chunk.toString("utf8"); }); child.stderr?.on("data", (chunk: Buffer) => { stderr += chunk.toString("utf8"); });
child.on("close", (code) => resolve({ exitCode: code ?? 0, stdout, stderr })); child.on("close", (code) => {
child.on("error", (error) => resolve({ exitCode: 1, stdout, stderr: String(error.message) })); const capped = { exitCode: code ?? 0, stdout, stderr: stderr.slice(0, 64 * 1024) };
if (process.env.P2_CHILD_DEBUG === "1" && (code ?? 0) !== 0) {
capped.stdout = stdout.slice(0, 4096);
capped.stderr = stderr.slice(0, 4096);
}
resolve(capped);
});
child.on("error", (error) => resolve({ exitCode: 1, stdout, stderr: String(error.message).slice(0, 4096) }));
}); });
} finally { } finally {
closeSync(configFd); closeSync(configFd);
@@ -427,7 +427,13 @@ export class WorkspacePreprocessingService {
private async runJsonStage(runtime: ActiveRuntime, argv: string[]): Promise<Record<string, unknown>> { private async runJsonStage(runtime: ActiveRuntime, argv: string[]): Promise<Record<string, unknown>> {
const result = await this.deps.runChild({ argv, configPath: runtime.configLease.path }); const result = await this.deps.runChild({ argv, configPath: runtime.configLease.path });
if (result.exitCode !== 0) throw new Error("workspace child failed"); if (result.exitCode !== 0) {
if (process.env.P2_CHILD_DEBUG === "1") {
const detail = `${result.stderr ?? ""}${result.stdout ?? ""}`.replace(/[\r\n]+/g, " ").slice(0, 2048);
throw new Error(`workspace child failed: ${detail}`);
}
throw new Error("workspace child failed");
}
return JSON.parse(result.stdout) as Record<string, unknown>; return JSON.parse(result.stdout) as Record<string, unknown>;
} }