Skip to content

Fix ASGI byte fields and request-body stalls - #21

Open
h0rv wants to merge 1 commit into
benoitc:mainfrom
h0rv:fix-asgi-http-bytes-and-body-lifecycle
Open

h0rv wants to merge 1 commit into
benoitc:mainfrom
h0rv:fix-asgi-http-bytes-and-body-lifecycle

Conversation

@h0rv

@h0rv h0rv commented Nov 17, 2026

Copy link
Copy Markdown

Fix ASGI byte fields and request-body stalls

Summary

Preserve ASGI wire bytes and prevent request-body EOF/backpressure stalls.
Erlang/Python text autodetection currently turns valid UTF-8 headers, query
strings, and small bodies into str; repeated post-EOF receive() calls can
also starve the application.

  • Explicitly convert header pairs, raw_path, query_string, and inline
    bodies to bytes. Decode only Unicode path/root_path, preserving mount
    semantics and duplicate headers.
  • Deliver one final body event, then wait for request termination. Response
    completion signals the receiver directly; a separate close-only channel
    signals peer disconnect and timeout without conflating them with body EOF.
  • Bound full-channel retries without losing terminal response/error messages.
    Keep lifecycle doubles isolated from native test discovery. No lifespan,
    WebSocket, or services redesign is included.

Dependency

Upgrade erlang_python from 5.0.0 to released 5.0.1 for its
pool-loop routing fix.
Disconnect notifications use async byte-channel reads, which can lose wakeups
across multiple pool loops in 5.0.0. Native regressions pass without a
pool-size override, using the default eight loops.

Verification

OTP 28 / Python 3.14.10, with released erlang_python 5.0.1:

PYTHONPATH=priv python -m pytest -q test/python
rebar3 eunit
sh test/http_lifecycle_double/run.sh
rebar3 ct
rebar3 xref

All commands pass. Common Test: 226 passed, 10 explicitly skipped. EUnit:
2 passed. Isolated lifecycle doubles: 13 passed. Xref: passed. The 21 Python
tests also pass on Python 3.12.16.

Eight native HTTP regressions cover wire bytes, cookies, inline/streamed
bodies, response completion, peer close before/after response start, and
request timeout. The busy-channel deadline is covered with isolated doubles;
production retains its existing unbounded body-channel capacity. This change
does not introduce a body-queue memory limit.

The full CI version matrix and dialyzer were not rerun. Native tests use
Python 3.14; 5.0.1 retains the dependency's eager NativeSupervisor forward
annotation, which needs a separate fix for Python 3.12/3.13 imports. Passing
focused worker tests on 3.12 is not a native-bridge compatibility claim.

Preserve wire bytes in HTTP scopes and request bodies. Distinguish body EOF from request termination so post-EOF receives suspend until the response finishes, the peer disconnects, or the request times out.

Bound full-channel retries without dropping terminal response messages. Use erlang_python 5.0.1 for reliable disconnect notifications across the default pool loops, and cover wire bytes and lifecycle paths with Python, native HTTP, and isolated-double regressions.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant