{"record":{"id":"3944d6be667b1e4f","repo":"iOfficeAI/OfficeCLI","slug":"render-exited-exitcode","errorCode":null,"errorMessage":"render exited {exitCode}","messagePattern":"render exited (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/officecli/Core/Watch/WatchServer.cs","lineNumber":2697,"sourceCode":"                        var drainOut = proc.StandardOutput.ReadToEndAsync(renderCts.Token);\n                        try\n                        {\n                            await proc.WaitForExitAsync(renderCts.Token);\n                        }\n                        catch (OperationCanceledException)\n                        {\n                            try { proc.Kill(entireProcessTree: true); } catch { }\n                            throw new InvalidOperationException(\"render timed out after 120s\");\n                        }\n                        renderErr = await drainErr;\n                        _ = await drainOut;\n                        exitCode = proc.ExitCode;\n                    }\n                }\n                if (exitCode != 0 || !File.Exists(tmpOut))\n                {\n                    var reason = string.IsNullOrWhiteSpace(renderErr) ? $\"render exited {exitCode}\" : renderErr.Trim();\n                    throw new InvalidOperationException(reason);\n                }\n                html = await File.ReadAllTextAsync(tmpOut, token);\n            }\n            catch (Exception ex) when (ex is not OperationCanceledException)\n            {\n                var sb500 = new StringBuilder(\"{\\\"error\\\":\");\n                AppendJsonString(sb500, $\"failed to render {Path.GetFileName(newPath)}: {ex.Message}\");\n                sb500.Append('}');\n                await WriteJsonResponseAsync(stream, 500, \"Internal Server Error\", sb500.ToString(), token);\n                return;\n            }\n            finally\n            {\n                try { if (File.Exists(tmpOut)) File.Delete(tmpOut); } catch { }\n            }\n\n            // HTML in hand — swap state. Serialized so concurrent switches\n            // can't interleave their pipe/marker swaps.","sourceCodeStart":2679,"sourceCodeEnd":2715,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/Watch/WatchServer.cs#L2679-L2715","documentation":"Thrown by the render path when the child renderer exits with a non-zero code or produced no output file, and stderr was empty/blank. When stderr is non-empty the actual stderr text is used as the reason instead. The thrown message (either 'render exited <code>' or the trimmed stderr) is wrapped into the watch server's 500 JSON response.","triggerScenarios":"The `view <file> html` renderer failed: corrupt/unreadable source file, unsupported feature causing the renderer to error, missing dependency, or any non-zero exit with no output produced.","commonSituations":"Source file is malformed; renderer dependency missing in the environment; an unsupported OOXML construct the renderer chokes on; out-of-memory.","solutions":["If stderr is available, read it — the server prefers stderr text over the bare exit code.","Validate/open the source file in Office to confirm it is not corrupt.","Ensure the renderer and its dependencies are installed in the environment.","Reproduce the render standalone (`view <file> html --out x.html`) to capture the full stderr."],"exampleFix":"# reproduce standalone to see the real error\nofficecli view broken.pptx html --out /tmp/out.html\n# fix or replace the source, then the watch will re-render","handlingStrategy":"try-catch","validationCode":"// Pre-validate the file opens before relying on watch render\nif (!System.IO.File.Exists(path) || new System.IO.FileInfo(path).Length == 0)\n    throw new InvalidOperationException(\"source file missing or empty\");","typeGuard":null,"tryCatchPattern":"// The watch server returns HTTP 500 with {\"error\":\"failed to render <file>: <reason>\"}.\n// Client: parse the JSON error; reproduce `view <file> html` to get full diagnostics.","preventionTips":["Reproduce failing renders standalone to capture complete stderr.","Validate source files are well-formed Office documents before watching."],"tags":["watch","render","subprocess","error"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}