Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

test(close_base_llm): isolate #3816 FD-leak canaries to a serial no-coverage CI step (#4373)

LearningCircuitcc88e25f2177
diff --git a/.github/workflows/docker-tests.yml b/.github/workflows/docker-tests.yml
index 353bfeb8e1..e96f328db1 100644
--- a/.github/workflows/docker-tests.yml
+++ b/.github/workflows/docker-tests.yml
@@ -197,12 +197,36 @@ jobs:
-q \
--durations=20 \
-n auto \
- -m 'not integration' \
+ -m 'not integration and not fd_canary' \
--ignore=tests/ui_tests \
--ignore=tests/infrastructure_tests \
--ignore=tests/api_tests_with_login \
--ignore=tests/fuzz"
+ # fd_canary tests (#3816 FD-leak guards) are CPU-bound real-event-loop
+ # spins. Under coverage tracing + '-n auto' contention they blow past
+ # the global 60s timeout and pressure xdist workers into crashing.
+ # Run them in a dedicated SERIAL step with NO coverage and NO '-n auto'
+ # so the FD-count signal stays deterministic (~10s) without flaking.
+ - name: Run fd_canary FD-leak tests (serial, no coverage)
+ if: always()
+ run: |
+ docker run --rm \
+ -v "$PWD":/app \
+ -e CI=true \
+ -e GITHUB_ACTIONS=true \
+ -e LDR_TESTING_WITH_MOCKS=true \
+ -e LDR_DISABLE_RATE_LIMITING=true \
+ -e PYTHONPATH=/app/src \
+ -w /app \
+ ${{ env.TEST_IMAGE }} \
+ sh -c "python -m pytest tests/utilities/test_close_base_llm.py \
+ -m fd_canary \
+ -p no:cov \
+ --tb=short \
+ --no-header \
+ -q"
+
- name: Run JavaScript infrastructure tests
if: always()
run: |
diff --git a/pyproject.toml b/pyproject.toml
index c62bc34bb0..479b786503 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -185,6 +185,7 @@ markers = [
"integration: marks integration tests",
"slow: marks slow tests",
"asyncio: marks async tests that use asyncio",
+ "fd_canary: heavy file-descriptor-leak regression tests (#3816). CPU-bound real-event-loop spins that exceed the global 60s timeout under coverage + '-n auto' contention; run in a dedicated serial, no-coverage CI step instead of the parallel suite.",
]
# Global timeout for all tests - fail fast instead of hanging
timeout = 60
diff --git a/tests/utilities/test_close_base_llm.py b/tests/utilities/test_close_base_llm.py
index a0ba1122cf..ee07901868 100644
--- a/tests/utilities/test_close_base_llm.py
+++ b/tests/utilities/test_close_base_llm.py
@@ -361,6 +361,8 @@ class TestCloseBaseLLMRealHttpxAsync:
assert async_httpx.is_closed is True
+ @pytest.mark.fd_canary
+ @pytest.mark.timeout(180)
@pytest.mark.skipif(
sys.platform == "win32",
reason="Linux/macOS-specific FD semantics",
@@ -418,6 +420,8 @@ class TestCloseBaseLLMRealHttpxAsync:
f"before={before}, after={after}"
)
+ @pytest.mark.fd_canary
+ @pytest.mark.timeout(120)
@pytest.mark.skipif(
sys.platform == "win32",
reason="Linux/macOS-specific FD semantics",
@@ -466,113 +470,6 @@ class TestCloseBaseLLMRealHttpxAsync:
)
-class TestAsyncioSubprocessFDBaseline:
- """Canary for the *other* FD class that production has leaked from:
- ``anon_inode:[pidfd]`` opened by ``asyncio.create_subprocess_exec``.
-
- Background (Wave 7 / Round 8): production observed ~3.6 pidfds/hour
- in steady state, all targeting ``Pid: -1`` (exited children).
- Traced to Playwright's Node.js driver being spawned via
- ``asyncio.create_subprocess_exec`` and failing because Chromium
- isn't installed in the production image — but the pidfd opened by
- the child watcher wasn't promptly closed on the failed-child exit.
- Fixed by PR #3971 (disable JS rendering by default) which
- short-circuits before any subprocess is spawned.
-
- These tests don't exercise LDR's own code directly — LDR itself
- doesn't call ``asyncio.create_subprocess_*`` (R8C1 audit confirmed).
- Instead they pin the *platform baseline*: on this Python version,
- repeated ``asyncio.create_subprocess_exec`` cycles of a fast-exiting
- child must not leak FDs. If a future Python upgrade, child-watcher
- change, or dependency hook breaks the close semantics, CI fails
- here on the next PR — which is the canary signal we want.
-
- Skip on non-Linux: ``/bin/true`` isn't universally available on
- Windows; pidfd_open is Linux-only. macOS has ``/bin/true`` but uses
- a different child watcher (no pidfd), so the test still passes there
- by virtue of nothing to leak. Restricting to Linux keeps the signal
- sharp.
- """
-
- @pytest.mark.skipif(
- sys.platform != "linux",
- reason="pidfd_open is Linux-only; asyncio child watcher behavior differs elsewhere",
- )
- def test_no_fd_growth_across_asyncio_subprocess_cycles(self):
- """Repeated ``asyncio.create_subprocess_exec`` of ``/bin/true``
- must not leak FDs. A real regression of this class would push
- the delta well past the +2 slack (this is the same slack we
- use for the eventpoll tests above; a 1-FD-per-iter leak across
- 10 iterations would land at delta=10).
- """
-
- async def _spawn_and_wait():
- proc = await asyncio.create_subprocess_exec(
- "/bin/true",
- stdout=asyncio.subprocess.DEVNULL,
- stderr=asyncio.subprocess.DEVNULL,
- )
- await proc.wait()
-
- gc.collect()
- before = _open_fd_count()
-
- for _ in range(10):
- asyncio.run(_spawn_and_wait())
- gc.collect()
-
- gc.collect()
- after = _open_fd_count()
-
- assert after - before <= 2, (
- f"FD count climbed across asyncio.create_subprocess_exec "
- f"cycles — likely a pidfd or eventpoll leak in the child "
- f"watcher: before={before}, after={after}"
- )
-
- @pytest.mark.skipif(
- sys.platform != "linux",
- reason="pidfd_open is Linux-only",
- )
- def test_no_fd_growth_when_subprocess_fails_to_exec(self):
- """The Wave-7 production shape was a child that exec'd a binary
- that **didn't exist** (Chromium missing). The pidfd was opened
- before exec; if the exec failed, the child watcher still has to
- close the pidfd cleanly. This pins that path.
- """
-
- async def _spawn_missing_binary():
- # An intentionally-not-installed path. The kernel returns
- # ENOENT on the exec; the child watcher must still clean up.
- try:
- proc = await asyncio.create_subprocess_exec(
- "/nonexistent/binary/for/ldr/fd/test",
- stdout=asyncio.subprocess.DEVNULL,
- stderr=asyncio.subprocess.DEVNULL,
- )
- await proc.wait()
- except (FileNotFoundError, OSError):
- # Expected: exec failed.
- pass
-
- gc.collect()
- before = _open_fd_count()
-
- for _ in range(10):
- asyncio.run(_spawn_missing_binary())
- gc.collect()
-
- gc.collect()
- after = _open_fd_count()
-
- assert after - before <= 2, (
- f"FD count climbed across failed-exec asyncio.create_subprocess "
- f"cycles — exact Wave-7 shape (Playwright Node.js driver "
- f"failing because Chromium isn't installed). "
- f"before={before}, after={after}"
- )
-
-
class TestCloseBaseLLMRealLangchain:
"""End-to-end regression coverage against the real langchain LLM classes
users actually instantiate. Guards against: