{"record":{"id":"6076d331d067f251","repo":"nodejs/node","slug":"failed-to-write-output-s-s-n","errorCode":null,"errorMessage":"failed to write output [%s]: %s\\n","messagePattern":"failed to write output \\[(.+?)\\]: (.+?)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/brotli/c/tools/brotli.c","lineNumber":1109,"sourceCode":"  context->next_in = context->input;\n  if (ferror(context->fin)) {\n    fprintf(stderr, \"failed to read input [%s]: %s\\n\",\n            PrintablePath(context->current_input_path), strerror(errno));\n    return BROTLI_FALSE;\n  }\n  return BROTLI_TRUE;\n}\n\n/* Internal: should be used only in Provide-/Flush-Output. */\nstatic BROTLI_BOOL WriteOutput(Context* context) {\n  size_t out_size = (size_t)(context->next_out - context->output);\n  context->total_out += out_size;\n  if (out_size == 0) return BROTLI_TRUE;\n  if (context->test_integrity) return BROTLI_TRUE;\n\n  fwrite(context->output, 1, out_size, context->fout);\n  if (ferror(context->fout)) {\n    fprintf(stderr, \"failed to write output [%s]: %s\\n\",\n            PrintablePath(context->current_output_path), strerror(errno));\n    return BROTLI_FALSE;\n  }\n  return BROTLI_TRUE;\n}\n\nstatic BROTLI_BOOL ProvideOutput(Context* context) {\n  if (!WriteOutput(context)) return BROTLI_FALSE;\n  context->available_out = kFileBufferSize;\n  context->next_out = context->output;\n  return BROTLI_TRUE;\n}\n\nstatic BROTLI_BOOL FlushOutput(Context* context) {\n  if (!WriteOutput(context)) return BROTLI_FALSE;\n  context->available_out = 0;\n  context->next_out = context->output;\n  return BROTLI_TRUE;","sourceCodeStart":1091,"sourceCodeEnd":1127,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/brotli/c/tools/brotli.c#L1091-L1127","documentation":"After `fwrite` of the output buffer, `ferror(context->fout)` is set, meaning the write failed. The message shows the output path and errno string. This aborts the operation; the output file is likely incomplete or corrupt.","triggerScenarios":"Disk full (ENOSPC); write to a full quota; broken pipe (EPIPE) when outputting to stdout/another process that exited; read-only filesystem (EROFS); I/O error on the output device.","commonSituations":"Output disk filled during compression of a large/incompressible file; piping brotli output to a consumer that exits before reading everything; writing to a mounted-but-read-only filesystem; network share write timeout.","solutions":["Check free space on the output filesystem: `df -h <output_dir>`.","If piping to another process, ensure it reads all data before exiting (avoid `| head`).","Verify the output filesystem is mounted read-write: `mount | grep <dir>`.","Check user quota: `quota -s`.","Clean up partial output and re-run after resolving the underlying issue."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"#include <sys/statvfs.h>\n#include <stdbool.h>\n\nbool output_writable_with_space(const char *dir, unsigned long long min_bytes) {\n    struct statvfs vfs;\n    if (statvfs(dir, &vfs) != 0) return false;\n    unsigned long long avail = (unsigned long long)vfs.f_bavail * vfs.f_bsize;\n    return avail > min_bytes;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-check free disk space and quota before writing large outputs.","Never pipe brotli output to `head`, `tail`, or any command that may exit early.","Monitor write errors in CI logs and fail the job if the output is truncated."],"tags":["io","write-error","disk-full","brotli"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}