Seldaek/monolog · error · InvalidArgumentException

Timeout must be 0 or a positive float (got $value)

Error message

Timeout must be 0 or a positive float (got $value)

What it means

Error "Timeout must be 0 or a positive float (got $value)" thrown in Seldaek/monolog.

Source

Thrown at src/Monolog/Handler/SocketHandler.php:324

    /**
     * Wrapper to allow mocking
     *
     * @return mixed[]|bool
     */
    protected function streamGetMetadata(): array|bool
    {
        if (!\is_resource($this->resource)) {
            throw new \LogicException('streamGetMetadata called but $this->resource is not a resource');
        }

        return stream_get_meta_data($this->resource);
    }

    private function validateTimeout(float $value): void
    {
        if ($value < 0) {
            throw new \InvalidArgumentException("Timeout must be 0 or a positive float (got $value)");
        }
    }

    private function connectIfNotConnected(): void
    {
        if ($this->isConnected()) {
            return;
        }
        $this->connect();
    }

    protected function generateDataStream(LogRecord $record): string
    {
        return (string) $record->formatted;
    }

    /**
     * @return resource|null

View on GitHub (pinned to 57eb102834)

When it happens

Trigger: Thrown at src/Monolog/Handler/SocketHandler.php:324 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of Seldaek/monolog@57eb102834 (2026-08-17). Data as JSON: /api/errors/882a0c4e610c2a3d. Report an issue: GitHub.