ITADN

~invalid Read on closed Body" when using reverse_proxy and error handler

#7713Openjameshartig 创建于 2026-05-12
J
jameshartigcommented
### Issue Details The following config triggers this error (assuming you have nothing running on port 9999): <details> <summary>config.json</summary> ```json { "admin": { "disabled": true }, "logging": { "sink": { "writer": { "output": "stderr" } }, "logs": { "default": { "level": "DEBUG" } } }, "apps": { "http": { "servers": { "default": { "listen": [ ":8888" ], "automatic_https": { "disable": true }, "routes": [ { "handle": [ { "handler": "subroute", "routes": [ { "handle": [ { "handler": "reverse_proxy", "health_checks": { "passive": { "fail_duration": "3s", "max_fails": 1, "unhealthy_status": [] } }, "transport": { "protocol": "http" }, "upstreams": [ { "dial": "127.0.0.1:9999" } ] } ], "terminal": true } ], "errors": { "routes": [ { "match": [ { "vars": { "{http.error.status_code}": [ "502", "503" ] } } ], "handle": [ { "handler": "reverse_proxy", "transport": { "protocol": "http" }, "upstreams": [ { "dial": "1.1.1.1:443" } ] } ], "terminal": true } ] } } ], "terminal": true } ] } } } } } ``` </details> A POST request (`curl -v http://127.0.0.1:8888/ -d 'hi'`) will return a 502 error and log: > 2026/05/12 01:09:47.086 ERROR http.log.error http: invalid Read on closed Body {"request": {"remote_ip": "127.0.0.1", "remote_port": "59066", "client_ip": "127.0.0.1", "proto": "HTTP/1.1", "method": "POST", "host": "127.0.0.1:8888", "uri": "/api", "headers": {"Accept": ["*/*"], "Content-Length": ["2"], "Content-Type": ["application/x-www-form-urlencoded"], "User-Agent": ["curl/8.5.0"]}}, "duration": 0.00084688, "status": 502, "err_id": "6n3snegru", "err_trace": "reverseproxy.statusError (reverseproxy.go:1525)"} But if you issue another POST within 3 seconds it'll work because the failed upstream is cached and it bypasses trying again. However, the experience of a failed request every 3 seconds is still bad. I believe this is related to #7546 and #7547 but those specifically were fixing it for retries and this is a different form of a retry via an error handler. There probably needs to be a better solution to the body being closed rather than inspecting to see if retries are enabled or not. ### Assistance Disclosure AI not used ### If AI was used, describe the extent to which it was used. _No response_
0 条评论