flarum/framework · error · Exception

$errno, $errstr, $errfile:$errline

Error message

$errno, $errstr, $errfile:$errline

What it means

ServeCommand installs a PHP error handler while running the realtime websocket server; non-fatal notices/warnings are suppressed (returns true), but any real PHP error is converted into a generic Exception whose message is just "$errno, $errstr, $errfile:$errline". This forces the server to stop on actual errors instead of continuing in a broken state.

Solutions

  1. Read the embedded $errstr, $errfile and $errline in the message — they point at the actual underlying error; fix that code first.
  2. Reproduce with the same code path outside the websocket server (normal HTTP request or unit test) to get a full stack trace.
  3. Check that all extensions enabled on the forum are compatible and load cleanly under the CLI/serve context.
  4. Verify required PHP extensions (sockets, mbstring, etc.) are installed for the user running the serve command.
Defensive patterns

Strategy: try-catch

Try / catch

try {
    $server->run();
} catch (\Exception $e) {
    // message embeds "errno, errstr, errfile:errline" — parse or log as-is for diagnosis
    logger()->error('Websocket serve crashed: ' . $e->getMessage());
}

Prevention

When it happens

Trigger: Any PHP error-level condition (E_ERROR-class, unhandled warning escalated, undefined function/class, failed include, type errors) raised during the websocket server's request loop while the custom error handler is active, e.g. a buggy extension listener invoked from a Message component.

Common situations: A listener or middleware referencing an undefined method/class on the server; missing PHP extension causing a fatal at runtime; file include failing in a long-running worker; extension code raising warnings that the configured error level escalates to exceptions.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of flarum/framework@4b939f6853 (2026-09-15). Data as JSON: /api/errors/d5c01e4bc2e60a14. Report an issue: GitHub.

Appendix: source

Thrown at extensions/realtime/src/Websocket/Console/ServeCommand.php:130

                ->enable($debug)
                ->verbose($this->output->isVerbose());
        });
    }

    public function errorHandler(int $errno, string $errstr, string $errfile, int $errline): bool
    {
        // Don't throw exceptions for deprecation notices, warnings, or notices in debug mode
        // Just log them to output instead
        if (in_array($errno, [E_DEPRECATED, E_USER_DEPRECATED, E_NOTICE, E_USER_NOTICE])) {
            if ($this->option('debug')) {
                $this->warn("[$errno] $errstr in $errfile:$errline");
            }

            return true;
        }

        // Throw exceptions for actual errors
        throw new \Exception("$errno, $errstr, $errfile:$errline");
    }

    /**
     * Expire stale index-typing presence and emit falling-edge "stopped typing"
     * signals, so list dots clear without each client running its own per-discussion
     * timer. Swept faster than the TTL (6s) to keep the clear-lag small.
     */
    protected function sweepIndexTyping(LoopInterface $loop): void
    {
        $presence = $this->getLaravel()->make(IndexTypingPresence::class);

        $loop->addPeriodicTimer(2, function () use ($presence) {
            $presence->sweep();
        });
    }

    /**
     * The daemon restarts on every deployment, so a fresh start signals that the

View on GitHub (pinned to 4b939f6853)