nodejs/node · error

write to standard output already set

Error message

write to standard output already set

What it means

The brotli `-c`/`--stdout` flag directs output to standard output. It may be given only once; a second occurrence is rejected.

Source

Thrown at deps/brotli/c/tools/brotli.c:349

      continue;
    }

    /* Simple / coalesced options. */
    if (arg[1] != '-') {
      size_t j;
      for (j = 1; j < arg_len; ++j) {
        char c = arg[j];
        if (c >= '0' && c <= '9') {
          if (quality_set) {
            fprintf(stderr, "quality already set\n");
            return COMMAND_INVALID;
          }
          quality_set = BROTLI_TRUE;
          params->quality = c - '0';
          continue;
        } else if (c == 'c') {
          if (output_set) {
            fprintf(stderr, "write to standard output already set\n");
            return COMMAND_INVALID;
          }
          output_set = BROTLI_TRUE;
          params->write_to_stdout = BROTLI_TRUE;
          continue;
        } else if (c == 'd') {
          if (command_set) {
            fprintf(stderr, "command already set when parsing -d\n");
            return COMMAND_INVALID;
          }
          command_set = BROTLI_TRUE;
          command = COMMAND_DECOMPRESS;
          continue;
        } else if (c == 'f') {
          if (params->force_overwrite) {
            fprintf(stderr, "force output overwrite already set\n");
            return COMMAND_INVALID;
          }

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Remove the duplicate `-c` so it appears once.
  2. Rebuild argv from a de-duplicated set when scripting.

Example fix

// before
brotli -c -c file
// after
brotli -c file
Defensive patterns

Strategy: validation

Validate before calling

assert sum(1 for a in argv if a in ('-c','--stdout') or (a.startswith('-') and not a.startswith('--') and 'c' in a)) <= 1

Prevention

When it happens

Trigger: Passing `-c` twice, e.g. `brotli -c -c file` or a coalesced `brotli -cc file`.

Common situations: An alias that includes `-c` and the user adding `-c` again; a wrapper concatenating flag groups.

Related errors


AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13). Data as JSON: /api/errors/580247091d793bf3. Report an issue: GitHub.