From b06338abf7a5be58151828acb801286c05a3d62a Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Wed, 7 Oct 2026 22:17:27 +0200 Subject: fix(client): stop the node at Quit in "only while open", whoever started it Switching from "at sign-in" to "only while MeshBay is open" left the node the sign-in launcher had started running after Quit: only a node this process had started was stopped. In that mode the app owns the node, so Quit stops the one that is there. The start with the app and the sign-in's own start (ensureNode) also both ran `autostart start` at launch -- three meshbay-node.exe were seen racing for the port. The sign-in's start and node:start now wait for the launch's. The end-to-end test covers the mode: Quit leaves no node, opening the app starts one. It launches the app with the environment it was imported with: the suite's conftest points HOME, USERPROFILE, LOCALAPPDATA and APPDATA at a throwaway directory per test, and the app started under that crashed at once (0x80000003), which first looked like a crash of the app itself. Co-Authored-By: Claude Opus 5.5 --- packages/meshbay-node/tests/test_packaging_win.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'packages/meshbay-node/tests/test_packaging_win.py') diff --git a/packages/meshbay-node/tests/test_packaging_win.py b/packages/meshbay-node/tests/test_packaging_win.py index 1fe6be8..b5f6191 100644 --- a/packages/meshbay-node/tests/test_packaging_win.py +++ b/packages/meshbay-node/tests/test_packaging_win.py @@ -1625,11 +1625,27 @@ def test_a_declined_prompt_leaves_the_node_as_it_was(): def test_only_while_open_starts_with_the_app_and_stops_at_quit(): main_js = MAIN_JS.read_text(encoding="utf-8") - start = _fn_body(main_js, "async function winStartNodeWithApp()") + start = _fn_body(main_js, "async function winStartNodeWithAppOnce()") assert "winStartupMode()) !== 'open'" in start and "nodeProvisioned()" in start assert "winNodeStartVia(['autostart', 'start'])" in start ready = main_js.split("app.whenReady().then(", 1)[1] assert ready.index("createWindow();") < ready.index("nodeWithApp.start()") quit_ = main_js.split("app.on('before-quit', (event) => {", 1)[1].split("\n });", 1)[0] - assert "!nodeStartedByApp" in quit_ and "event.preventDefault()" in quit_ - assert "mode === 'open' ? killNodeProcesses()" in quit_ + assert "event.preventDefault()" in quit_ + assert "(await winStartupMode()) !== 'open'" in quit_ and "killNodeProcesses()" in quit_ + # Whoever started it: a node left by the sign-in launcher before the mode + # was switched ran on after Quit (found on a real install, 2026-10-08). + assert "!nodeStartedByApp" not in quit_ + assert "await probeNode() || (await winNodePids()).length" in quit_ + + +def test_one_start_at_a_time_at_launch(): + """The start with the app and the sign-in's own both ran `autostart start` + at once: three meshbay-node.exe were seen racing for the port.""" + main_js = MAIN_JS.read_text(encoding="utf-8") + once = _fn_body(main_js, "async function winStartNodeWithApp()") + assert "if (!nodeWithAppStart) nodeWithAppStart = winStartNodeWithAppOnce();" in once + ensure = _fn_body(main_js, "async function ensureNode(opts)") + assert ensure.index("await nodeWithAppStart") < ensure.index("provisionNode(") + start = main_js.split("handle('node:start'", 1)[1][:600] + assert "await nodeWithAppStart" in start -- cgit v1.2.3