symfony/process · error · RuntimeException

" " is closed.

Error message

"%s" is closed.

What it means

Thrown from InputStream::write when attempting to append input after the stream has been closed (e.g. the underlying process ended or close() was called). Writes to a closed stream cannot be buffered, so a RuntimeException is raised.

Solutions

  1. Call isClosed() before writing to the stream
  2. Restructure code so writes finish before the process terminates
  3. Wrap write() calls in try-catch and discard input for closed streams
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at InputStream.php:49 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of symfony/process@99b85026db (2026-09-14). Data as JSON: /api/errors/8a8ad3e56f2e6efd. Report an issue: GitHub.

Appendix: source

Thrown at InputStream.php:49

     */
    public function onEmpty(?callable $onEmpty = null): void
    {
        $this->onEmpty = null !== $onEmpty ? $onEmpty(...) : null;
    }

    /**
     * Appends an input to the write buffer.
     *
     * @param resource|string|int|float|bool|\Traversable|null $input The input to append as scalar,
     *                                                                stream resource or \Traversable
     */
    public function write(mixed $input): void
    {
        if (null === $input) {
            return;
        }
        if ($this->isClosed()) {
            throw new RuntimeException(\sprintf('"%s" is closed.', static::class));
        }
        $this->input[] = ProcessUtils::validateInput(__METHOD__, $input);
    }

    /**
     * Closes the write buffer.
     */
    public function close(): void
    {
        $this->open = false;
    }

    /**
     * Tells whether the write buffer is closed or not.
     */
    public function isClosed(): bool
    {
        return !$this->open;

View on GitHub (pinned to 99b85026db)