NeMo-Relay icon indicating copy to clipboard operation
NeMo-Relay copied to clipboard

[Bug]: HTTP/1.1 128-stream concurrency tests in nemo-relay-cli fail on macOS with the default open-file limit (256)

Open Sakshitapkir03 opened this issue 3 weeks ago • 1 comments

Affected area

Build, packaging, or CI

Current behavior

On macOS with the default open-file limit (ulimit -n = 256; launchctl limit maxfiles = 256 unlimited), two nemo-relay-cli tests fail on every run, so just test-rust fails on a stock Mac:

  • daemon::common::transport::tests::pooled_http1_keeps_128_concurrent_streams_isolated
  • daemon::broker::server::daemon_worker_e2e_tests::full_hop_keeps_128_concurrent_http1_streams_isolated

The first error in each is os error 24 (from the accept loops of the in-process test servers in transport_tests.rs and daemon_worker_e2e_tests.rs), for example:

accept relay client: Os { code: 24, kind: Uncategorized, message: "Too many open files" }

The ConnectionReset, IncompleteMessage and 502 errors that follow are knock-on effects: the accept loop's expect panics, so later connections are never served.

These tests run the client and the test servers in one process, and each concurrent HTTP/1.1 stream holds its own connection per hop: about 4 descriptors per stream for the pooled test (client, relay and provider) and about 6 for the full hop, so 128 streams need roughly 512 and 768. The HTTP/2 variants multiplex each hop over one connection (the transport HTTP/2 test asserts exactly one connection per hop) and pass.

Measured on main at 12a36d49:

ulimit -n pooled HTTP/1.1 full-hop HTTP/1.1
256, 384, 512 fail fail
640, 768 pass fail (after ~31 s)
1024 pass pass

Expected behavior

I expected just test-rust to pass on a stock macOS setup without needing to raise the shell's open-file limit first. If a test needs more file descriptors than the environment allows, it should fail with a clear message rather than connection errors.

Steps to reproduce

  1. On macOS, open a new terminal with the default limit:
    ulimit -n   # 256
    
  2. From the repository root on main, run:
    cargo nextest run -p nemo-relay-cli -E 'test(~128_concurrent)'
    
  3. Observe that both HTTP/1.1 tests fail with os error 24: Too many open files, while both HTTP/2 tests pass.
  4. In the same terminal, run ulimit -n 1024 and rerun step 2: all four tests pass.

Environment

  • NeMo Relay version or commit: main at 12a36d49
  • OS and architecture: macOS 27.2 , Apple Silicon (arm64); default ulimit -n 256 (launchctl limit maxfiles: 256 unlimited)
  • Rust version: 1.96.1 (pinned by rust-toolchain.toml)
  • Python version: 3.12.15
  • Node.js version: v24.21.0
  • Go version: N/A (Go bindings not built)
  • Install/build command: from source per CONTRIBUTING.md (uv sync, just build-rust, just build-python); tests via just test-rust and cargo-nextest 0.9.133

Impact

This affects anyone running the Rust test suite on macOS with default settings: just test-rust fails with these two tests until the limit is raised. It does not appear to affect the product itself, since in real use the client, daemon, worker and provider are separate processes, each with its own limit.

Workaround: run ulimit -n 1024 (or higher) in the shell before running the tests.

Proposed fix: a small #[cfg(unix)] helper in tests/coverage/shared/test_support.rs that raises the process's soft RLIMIT_NOFILE to what the test needs (derived from STREAMS), never above the hard limit, and fails with an actionable message if the hard limit is too low. It is called before the test servers start, in the pooled HTTP/1.1 test and in the shared full-hop helper (where it is a no-op for the HTTP/2 variant's needs). It uses the existing libc dependency, is test-only, and does nothing wherever the soft limit already meets the requirement. Nextest runs each test in its own process, so the change does not leak.

I have this implemented and tested on a branch: with it, just test-rust passes on a stock Mac at ulimit -n 256 (6822 passed, 0 failed, 4 skipped). Happy to open a PR once you're OK with this approach.

Sakshitapkir03 avatar Nov 11 '26 23:11 Sakshitapkir03

@Sakshitapkir03 you can open a PR to address this. Please have it target the main branch.

willkill07 avatar Nov 12 '26 13:11 willkill07