You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Follow-up from reviewing #7508: the codex-native app-server event iterator still waits after its WebSocket reader exits. Native forwarding or thread discovery can remain blocked waiting for events that can no longer arrive, until an outer timeout or session teardown intervenes.
Current main includes #7355, which fixes pending response-bearing RPCs (closed issue #7352). Those RPCs now fail promptly. The remaining gap is CodexAppServerClient.iter_events(): it waits on _events.get(), while _reader_loop() exits without notifying that queue. The iterator's documented “until the connection closes” behavior therefore does not hold.
The production consumers include the native forwarder's event loop and wait_for_thread_started(). In particular, the latter's timeout=None path cannot reach its “event stream ended before thread startup” error after disconnect. This report establishes the client disconnect boundary; it does not establish a universal user-visible timeout or field frequency.
Steps to reproduce
Using the production client and a real loopback WebSocket server:
Complete the initialize handshake.
Start an event consumer and a turn/start RPC.
Close the server connection without replying, with close code 1000 (normal) or 1011 (error).
Wait for the reader to finish, then check both callers.
Expected: event consumers also wake and terminate or receive a disconnect error promptly, preserving notifications already queued before the disconnect. A caller should not need to discover the dead reader and cancel the consumer itself.
Self-contained reproduction (no credentials or Codex binary required)
After installing the checkout's frozen development dependencies, save this as /tmp/repro_native_event_disconnect.py:
OMNIGENT_DISABLE_KEYRING=1 PYTHONPATH="$PWD/sdks/python-client:$PWD/sdks/ui:$PWD" \
uv run --no-sync python /tmp/repro_native_event_disconnect.py
The assertions confirm the current defect; a successful run is reproduction evidence, not proof of a fix. The script cleans up its own tasks and connections.
Version
Main e047da5f734e0db77a6d4c32abb3dce433a2e216, using frozen dependencies. The six existing tests/test_codex_native_app_server_rpc.py tests also pass on this revision, confirming the RPC fix is retained while the event-consumer gap remains.
OS / Platform or device
macOS; local Python process and real loopback WebSockets. No live model provider, native Codex CLI, browser session, or Windows/Linux run was used for this reproduction.
Harness / Harness mode
Codex, Native (codex-native). #7508 addresses the separate request-driven codex harness.
Observed impact
Sessions whose app-server disconnects while a native event consumer is waiting. Frequency in production is unknown. Forwarding or thread discovery may remain pending rather than promptly recognizing the disconnected app-server.
Authentication type
Not authentication-related; the reproduction uses no credentials.
Fix scope and validation
Wake event consumers on normal disconnect, reader failure, and explicit close; preserve already-buffered notifications and use a fresh event queue after reconnect.
Exercise the production thread-discovery and forwarding consumers, including cancellation and cleanup, so stream termination results in the intended failure/teardown behavior.
Description
Follow-up from reviewing #7508: the
codex-nativeapp-server event iterator still waits after its WebSocket reader exits. Native forwarding or thread discovery can remain blocked waiting for events that can no longer arrive, until an outer timeout or session teardown intervenes.Current main includes #7355, which fixes pending response-bearing RPCs (closed issue #7352). Those RPCs now fail promptly. The remaining gap is
CodexAppServerClient.iter_events(): it waits on_events.get(), while_reader_loop()exits without notifying that queue. The iterator's documented “until the connection closes” behavior therefore does not hold.The production consumers include the native forwarder's event loop and
wait_for_thread_started(). In particular, the latter'stimeout=Nonepath cannot reach its “event stream ended before thread startup” error after disconnect. This report establishes the client disconnect boundary; it does not establish a universal user-visible timeout or field frequency.Steps to reproduce
Using the production client and a real loopback WebSocket server:
turn/startRPC.Observed on current main for both close codes:
{"close_code": 1000, "reader_finished": true, "rpc_error": "ConnectionError", "event_consumer_still_waiting": true} {"close_code": 1011, "reader_finished": true, "rpc_error": "ConnectionError", "event_consumer_still_waiting": true}Expected: event consumers also wake and terminate or receive a disconnect error promptly, preserving notifications already queued before the disconnect. A caller should not need to discover the dead reader and cancel the consumer itself.
Self-contained reproduction (no credentials or Codex binary required)
After installing the checkout's frozen development dependencies, save this as
/tmp/repro_native_event_disconnect.py:Run from the repository root:
OMNIGENT_DISABLE_KEYRING=1 PYTHONPATH="$PWD/sdks/python-client:$PWD/sdks/ui:$PWD" \ uv run --no-sync python /tmp/repro_native_event_disconnect.pyThe assertions confirm the current defect; a successful run is reproduction evidence, not proof of a fix. The script cleans up its own tasks and connections.
Version
Main
e047da5f734e0db77a6d4c32abb3dce433a2e216, using frozen dependencies. The six existingtests/test_codex_native_app_server_rpc.pytests also pass on this revision, confirming the RPC fix is retained while the event-consumer gap remains.OS / Platform or device
macOS; local Python process and real loopback WebSockets. No live model provider, native Codex CLI, browser session, or Windows/Linux run was used for this reproduction.
Harness / Harness mode
Codex, Native (
codex-native). #7508 addresses the separate request-drivencodexharness.Observed impact
Sessions whose app-server disconnects while a native event consumer is waiting. Frequency in production is unknown. Forwarding or thread discovery may remain pending rather than promptly recognizing the disconnected app-server.
Authentication type
Not authentication-related; the reproduction uses no credentials.
Fix scope and validation
Related work
codexharness.