Skip to content

tests: stop half-closing in the httpserver framing/chunked raw() helper - #1211

Merged
saghul merged 1 commit into
masterfrom
devteam/t_7692981b-httpserver-raw-halfclose
Nov 2, 2026
Merged

saghul merged 1 commit into
masterfrom
devteam/t_7692981b-httpserver-raw-halfclose

Conversation

@saghul

@saghul saghul commented Nov 2, 2026

Copy link
Copy Markdown
Owner

What

In tests/test-httpserver-chunked.js and tests/test-httpserver-framing.js, the raw() helper no longer half-closes the socket (writer.close()) before reading the response. It now reads until EOF, bounded by one overall 5 s deadline per call (its timer is cleared when the loop ends), instead of a 500 ms per-read idle race. Assertions and request bytes are unchanged. The TJS_GC_STRESS skip in the chunked test is removed, since the read-timeout race it blamed is gone.

Why

The lws h1 server treats the client's FIN as a full close and closes the connection at once. If the JS handler hasn't written its response yet, the response is dropped and the client sees EOF, so raising the timeout would not help. That is why these tests flaked on macOS Debug and in GC Stress (Linux). Every request already sends Connection: close, so the server always closes after answering and EOF always arrives. The server behaviour itself is tracked separately.

Refs #1207

How verified

A local-only repro adds await new Promise(r => setTimeout(r, Number(tjs.env.HDELAY || 0))); after const body = await req.text(); in each handler. This line is not committed.

  • master: HDELAY=200 tjs run chunked 0/5 (valid split chunked body is echoed); HDELAY=200 and HDELAY=0 tjs run framing 0/5 each (plain Content-Length request is accepted)
  • this PR: all three pass 5/5
  • unmodified tests: 20/20 each, max 0.39 s (chunked) / 0.12 s (framing) per run
  • ./build/tjs test tests/: all pass; make lint: clean

Devteam card: t_7692981b

The lws h1 server treats the client's FIN as a full close and drops a response the handler hasn't written yet, so half-closing before reading made these tests flaky. Read until EOF (every request sends Connection: close) with one 5 s deadline instead of a 500 ms per-read race, and drop the GC stress skip in the chunked test.

Refs #1207
@saghul

saghul commented Nov 2, 2026

Copy link
Copy Markdown
Owner Author

Reviewer verdict (devteam t_7692981b): approved at 90fffd0.

  • Both raw() helpers no longer half-close before reading. They read to EOF under one 5 s deadline, and its timer is cleared. Assertions and request bytes are unchanged, and the GC-stress skip is gone.
  • Repro with a local-only handler delay line (5 runs each): on master, chunked failed 0/5 with HDELAY=200 and 50, and framing failed 0/5 with HDELAY=200 and 0. With this PR every case passes 5/5.
  • Deadline path: with HDELAY=7000, framing fails on its own assertion after 5.05 s.
  • Unmodified tests pass 20/20 each (max 0.31 s / 0.05 s). tjs test tests/ exits 0 and make lint is clean.
  • CI: 39 pass, 1 skipped (release). GC Stress (Linux) ran both tests, and both were OK.
  • No deep-review trigger applies: the PR is test-only, changes 2 files and 49 lines, and touches no product code.

@saghul
saghul merged commit ba66468 into master Nov 2, 2026
75 of 76 checks passed
@saghul
saghul deleted the devteam/t_7692981b-httpserver-raw-halfclose branch November 2, 2026 23:26
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