{"record":{"id":"5f6b2d9b925b8168","repo":"ratchetphp/Ratchet","slug":"a-react-loop-was-not-provided-during-instantiation","errorCode":null,"errorMessage":"A React Loop was not provided during instantiation","messagePattern":"A React Loop was not provided during instantiation","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Ratchet/Server/IoServer.php","lineNumber":79,"sourceCode":"     * @return IoServer\n     */\n    public static function factory(MessageComponentInterface $component, $port = 80, $address = '0.0.0.0') {\n        // prefer default Loop (reactphp/event-loop v1.2+) over legacy \\React\\EventLoop\\Factory\n        $loop = class_exists('React\\EventLoop\\Loop') ? Loop::get() : LegacyLoopFactory::create();\n\n        // prefer SocketServer (reactphp/socket v1.9+) over legacy \\React\\Socket\\Server\n        $socket = class_exists('React\\Socket\\SocketServer') ? new SocketServer($address . ':' . $port, [], $loop) : new LegacySocketServer($address . ':' . $port, $loop);\n\n        return new static($component, $socket, $loop);\n    }\n\n    /**\n     * Run the application by entering the event loop\n     * @throws \\RuntimeException If a loop was not previously specified\n     */\n    public function run() {\n        if (null === $this->loop) {\n            throw new \\RuntimeException(\"A React Loop was not provided during instantiation\");\n        }\n\n        // @codeCoverageIgnoreStart\n        $this->loop->run();\n        // @codeCoverageIgnoreEnd\n    }\n\n    /**\n     * Triggered when a new connection is received from React\n     * @param \\React\\Socket\\ConnectionInterface $conn\n     */\n    public function handleConnect(SocketConnection $conn) {\n        // assign dynamic `$decor` property used by Ratchet without raising notice on PHP 8.2+\n        // need this hack because we can't use `#[\\AllowDynamicProperties]` on vendor code\n        set_error_handler(function () { }, E_DEPRECATED);\n        $conn->decor = new IoConnection($conn);\n        restore_error_handler();\n","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/ratchetphp/Ratchet/blob/e621c6c40bf684bbbb877102416ad5303d05a9cc/src/Ratchet/Server/IoServer.php#L61-L97","documentation":"IoServer::run() requires the React event loop that was bound to the server at construction time. This error signals that the IoServer instance was created without a LoopInterface (constructor received null) — typically by using new IoServer($app, $socket) directly instead of IoServer::factory(), which creates a loop automatically. run() cannot start the server because there is no loop to run; the guard converts a null-property condition into a clear configuration error.","triggerScenarios":"Thrown at src/Ratchet/Server/IoServer.php:79 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Build the server with IoServer::factory($component, $port, $address), which constructs a React loop and socket automatically.","If constructing manually, pass a loop: new IoServer($app, $socket, React\\EventLoop\\Loop::get()) or an explicit Factory::create() loop.","Store the loop you pass to the socket server and reuse it for the IoServer so both share the same event loop instance."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e621c6c40bf684bbbb877102416ad5303d05a9cc","analyzedAt":"2026-09-16T00:13:27.878Z","contentChangedAt":"2026-09-16T00:13:27.878Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}