nodejs/node · error
failed to write output [%s]: %s\n
Error message
failed to write output [%s]: %s\n
What it means
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.
Source
Thrown at deps/brotli/c/tools/brotli.c:1109
context->next_in = context->input;
if (ferror(context->fin)) {
fprintf(stderr, "failed to read input [%s]: %s\n",
PrintablePath(context->current_input_path), strerror(errno));
return BROTLI_FALSE;
}
return BROTLI_TRUE;
}
/* Internal: should be used only in Provide-/Flush-Output. */
static BROTLI_BOOL WriteOutput(Context* context) {
size_t out_size = (size_t)(context->next_out - context->output);
context->total_out += out_size;
if (out_size == 0) return BROTLI_TRUE;
if (context->test_integrity) return BROTLI_TRUE;
fwrite(context->output, 1, out_size, context->fout);
if (ferror(context->fout)) {
fprintf(stderr, "failed to write output [%s]: %s\n",
PrintablePath(context->current_output_path), strerror(errno));
return BROTLI_FALSE;
}
return BROTLI_TRUE;
}
static BROTLI_BOOL ProvideOutput(Context* context) {
if (!WriteOutput(context)) return BROTLI_FALSE;
context->available_out = kFileBufferSize;
context->next_out = context->output;
return BROTLI_TRUE;
}
static BROTLI_BOOL FlushOutput(Context* context) {
if (!WriteOutput(context)) return BROTLI_FALSE;
context->available_out = 0;
context->next_out = context->output;
return BROTLI_TRUE;View on GitHub (pinned to 1b2de5e052)
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.
Defensive patterns
Strategy: validation
Validate before calling
#include <sys/statvfs.h>
#include <stdbool.h>
bool output_writable_with_space(const char *dir, unsigned long long min_bytes) {
struct statvfs vfs;
if (statvfs(dir, &vfs) != 0) return false;
unsigned long long avail = (unsigned long long)vfs.f_bavail * vfs.f_bsize;
return avail > min_bytes;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- fclose failed [%s]: %s\n
- failed to open input file [%s]: %s\n
- failed to open output file [%s]: %s\n
- failed to open dictionary file [%s]: %s\n
- could not get size of dictionary file [%s]
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/6076d331d067f251.
Report an issue: GitHub.