{"record":{"id":"e8fb1d787e1f4e5b","repo":"gohugoio/hugo","slug":"error-reading-from-stdin","errorCode":null,"errorMessage":"Error reading from stdin","messagePattern":"Error reading from stdin","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"internal/warpc/js/common.js","lineNumber":28,"sourceCode":"\t};\n\n\tconsole.error = (value) => {\n\t\tthrow new Error(value);\n\t};\n\n\t// Read all the available bytes\n\twhile (true) {\n\t\t// Stdin file descriptor\n\t\tconst fd = 0;\n\t\tlet bytesRead = 0;\n\t\ttry {\n\t\t\tbytesRead = Javy.IO.readSync(fd, buffer);\n\t\t} catch (e) {\n\t\t\t// IO.readSync fails with os error 29 when stdin closes.\n\t\t\tif (e.message.includes('os error 29')) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tthrow new Error('Error reading from stdin');\n\t\t}\n\n\t\tif (bytesRead < 0) {\n\t\t\tthrow new Error('Error reading from stdin');\n\t\t\tbreak;\n\t\t}\n\n\t\tif (bytesRead === 0) {\n\t\t\tbreak;\n\t\t}\n\n\t\tcurrentLine = [...currentLine, ...buffer.subarray(0, bytesRead)];\n\n\t\t// Check for newline. If not, we need to read more data.\n\t\tif (!currentLine.includes(10)) {\n\t\t\tcontinue;\n\t\t}\n","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/internal/warpc/js/common.js#L10-L46","documentation":"The readInput loop calls Javy.IO.readSync on fd 0 (stdin). When that call throws and the error message does not contain 'os error 29' (the expected ESPIPE signal that stdin has closed), it rethrows a generic 'Error reading from stdin' because the underlying failure is unknown and uncategorised.","triggerScenarios":"Javy.IO.readSync throws an OS error other than 29 (e.g. bad file descriptor, permission denied, host I/O fault) while consuming the JSONL request stream.","commonSituations":"The stdin pipe is broken or aborted abnormally; the host process feeding the WASM module crashed; fd 0 was redirected to an unreadable source.","solutions":["Verify the host feeds a valid, open stdin pipe for the full lifetime of the warpc invocation","Ensure the producer closes stdin with EOF (os error 29) rather than aborting the pipe","Inspect host-side logs for the underlying OS error"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { readInput(handle); } catch (e) { if (e.message === 'Error reading from stdin') { abortGracefully(); } else throw e; }","preventionTips":["Keep the stdin pipe open for the full lifetime of the warpc invocation","Close stdin with EOF rather than aborting the pipe mid-stream"],"tags":["warpc","wasm","stdin","io","javascript"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}