phacility/phabricator · error · Exception

Failed to close file "%s".

Error message

Failed to close file "%s".

What it means

Closing the output failed: fclose/gzclose did not return true. With buffered writes, the close is where an out-of-space condition or I/O error often surfaces, after individual writes appeared to succeed. The workflow throws, and its exception handler removes the incomplete output file, so no truncated dump survives.

Source

Thrown at src/infrastructure/storage/management/workflow/PhabricatorStorageManagementRenamespaceWorkflow.php:189

        }

        if ($bytes !== strlen($data)) {
          throw new Exception(
            pht(
              'Failed to write %d byte(s) to "%s".',
              new PhutilNumber(strlen($data)),
              $output_name));
        }
      }

      if ($is_compress) {
        $ok = gzclose($file);
      } else {
        $ok = fclose($file);
      }

      if ($ok !== true) {
        throw new Exception(
          pht(
            'Failed to close file "%s".',
            $output_file));
      }
    } catch (Exception $ex) {
      try {
        if ($output_file !== null) {
          Filesystem::remove($output_file);
        }
      } catch (Exception $ex) {
        // Ignore any exception.
      }

      throw $ex;
    }

    // Give the user a chance to catch things if the results are crazy.
    $console->writeErr(

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Free space on the target filesystem and re-run the whole command — the partial file was removed automatically.
  2. Write --output to reliable local disk, then copy the finished file to network storage.
  3. If it recurs on the same device, suspect the medium or filesystem (check dmesg, consider fsck).
Defensive patterns

Strategy: try-catch

Try / catch

try {
  // run the renamespace workflow
} catch (Exception $ex) {
  // close failed; partial output was removed — free space before retrying
  fwrite(STDERR, $ex->getMessage()."\n");
  exit(1);
}

Prevention

When it happens

Trigger: Disk or quota exhausted exactly at flush time; NFS or FUSE filesystems failing the final flush; a medium or filesystem error on close.

Common situations: Output on NFS with quotas; small tmpfs targets; per-user quotas enforced at flush; marginal or failing disks.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/b5235e4416b2aba3. Report an issue: GitHub.