Conversation
The previous flow sent the 4xx response (413/404/401) and let the socket close with the request body still buffered. Windows TCP turns close-with-unread-bytes into RST, which the client surfaces as WinError 10053 *before* the response is read — masking the status and intermittently flaking test_oversize_body_rejected on CI runners. Now every early-return path drains the declared body in 64 KiB chunks (capped at 4× the body limit so a hostile Content-Length can't make us spin), guaranteeing a clean FIN close and a readable 4xx on the client side.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Follow-up to PR #189. The headless test suite intermittently failed on Windows CI runners at
test_webhook_trigger.py::test_oversize_body_rejectedwithWinError 10053 (connection aborted)— masking the 4xx status the test was actually asserting.Root cause:
_WebhookHandler._read_body()sent413 Request Entity Too Largeand returned with the request body still buffered in the receive socket. Windows TCP turnsclose()with unread bytes into RST (not FIN), so the client got an aborted-connection error before it could read the 413 response.Fix: a new
_reject_with_drain(status, message, length)helper sends the 4xx, then discards up tomin(length, 4 × _MAX_BODY_BYTES)bytes fromrfilein 64 KiB chunks before the socket closes — clean FIN, response delivered. Applied to all three early-return paths in_dispatch(404 / 401 / 413). The 4× cap stops a hostileContent-Length: 9999999999from making the server spin.Test plan
pytest test/unit_test/headless/test_webhook_trigger.py— 13/13 pass locally.ruff check je_auto_control/utils/triggers/webhook_server.py— clean.pytest-headlessjobs that flaked on PR dev -> main: remote desktop, operations layer, USB passthrough, executor coverage #189.