From 41282b997e016da0773276a935434dd03631e1f3 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Fri, 4 Sep 2026 02:36:41 +0200 Subject: fix(node): MESHBAY_NODE_EVENT_LOOP=proactor to opt out of the selector loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Whether aiortc actually hangs on the ProactorEventLoop for a live peer (as opposed to the same-process loopback the tests use) is still open. This lets a Windows node keep the default loop for that comparison — and, if Proactor turns out fine, keep subprocess ffmpeg working without a code change. Co-Authored-By: Claude Sonnet 5 --- packages/meshbay-node/src/meshbay_node/platform.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'packages/meshbay-node/src') diff --git a/packages/meshbay-node/src/meshbay_node/platform.py b/packages/meshbay-node/src/meshbay_node/platform.py index 80aa6ae..2eab9e1 100644 --- a/packages/meshbay-node/src/meshbay_node/platform.py +++ b/packages/meshbay-node/src/meshbay_node/platform.py @@ -29,17 +29,23 @@ def force_utf8_stdio() -> None: def use_compatible_event_loop() -> None: """ - aiortc's ICE stack (aioice) does not run on Windows' default - ProactorEventLoop — a DataChannel handshake never completes and the - connection hangs. Select the SelectorEventLoop before the loop is created. + On Windows, select the SelectorEventLoop: aiortc's ICE stack does not + complete a loopback DataChannel handshake on the default ProactorEventLoop. Cost: SelectorEventLoop cannot spawn subprocesses on Windows, so ffmpeg streaming (asyncio.create_subprocess_exec in webrtc_server.py) does not work under it. The video path needs a thread-based runner on Windows — tracked for the port. No effect off Windows. + + Whether the hang is real for a live peer (vs. the same-process loopback in + the tests) is still being established: set MESHBAY_NODE_EVENT_LOOP=proactor + to keep the default loop and check. """ - if sys.platform == "win32": - asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) + if sys.platform != "win32": + return + if os.environ.get("MESHBAY_NODE_EVENT_LOOP", "").lower() == "proactor": + return + asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) # ── Directories ────────────────────────────────────────────────────────────── -- cgit v1.2.3