Skip to content

Interop test failure: chromium-rust x python (ws, noise, mplex) - StreamReset before ping data readΒ #1108

@acul71

Description

@acul71

Problem

The interop test between chromium-rust-v0.53 and python-v0.4 using websocket, noise, and mplex is failing. The Python listener receives a StreamReset exception when trying to read the ping payload, causing the test to timeout.

Error Details

Error in ping handler: StreamReset: 
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/libp2p/stream_muxer/mplex/mplex_stream.py", line 155, in _do_read
    data = self.incoming_data_channel.receive_nowait()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/trio/_channel.py", line 338, in receive_nowait
    raise trio.WouldBlock
trio.WouldBlock

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/libp2p/stream_muxer/mplex/mplex_stream.py", line 163, in _do_read
    data = await self.incoming_data_channel.receive()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ...
  File "/app/ping_test.py", line 423, in handle_ping
    payload = await stream.read(PING_LENGTH)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/libp2p/network/stream/net_stream.py", line 216, in read
    raise StreamReset() from error
libp2p.network.stream.exceptions.StreamReset

Test Configuration

  • Transport: websocket (ws)
  • Security: noise
  • Muxer: mplex
  • Versions: chromium-rust-v0.53 x python-v0.4

Observations

  1. The listener successfully receives the stream and starts reading
  2. A reset message arrives (likely from rust-libp2p) before or during the read operation
  3. The stream is reset before the ping payload (32 bytes) can be fully read
  4. This causes the test to timeout waiting for ping data

Potential Causes

  • Race condition: reset message arrives before ping data is fully transmitted/received
  • Stream lifecycle mismatch: rust-libp2p's ping behaviour may reset streams differently than expected
  • Data buffering: ping data might be in transit or buffered when reset is processed

Hint

The issue appears to be in how mplex handles stream resets when data is still available in the channel buffer. Consider checking if buffered data can be read before raising the reset exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions