Repository navigation
upgrade to v5: curl sometimes reports: curl: (92) HTTP/2 stream 1 was not closed cleanly: INTERNAL_ERROR (err 2) #2918
Copy link
Copy link
Closed
Description
version: v5.0.4
func main() {
os.Exit(cli.Run(new(options), func(ctx *cli.Context) error {
argv := ctx.Argv().(*options)
e := echo.New()
e.Logger = slog.New(slog.NewTextHandler(os.Stdout, nil))
e.Use(middleware.CORS("*"))
e.Use(middleware.RequestLogger())
e.Use(echoprometheus.NewMiddleware("echo"))
e.Static("/package/", argv.PackageDirectory)
log.Fatal(e.Start(fmt.Sprintf(":%d", argv.ListenPort)))
return nil
}))
}this service behind traefik proxy v3.6.10.
in small ratio cases, getting files curl -LOJ https://internal.com/package/xxx reports: curl: (92) HTTP/2 stream 1 was not closed cleanly: INTERNAL_ERROR (err 2)
Same issue happened on another web service with stream response
c.Response().Header().Add(echo.HeaderContentDisposition, fileName)
stream, err := getLogStream(c.Request().Context())
if err != nil {
return err
}
defer stream.Close()
return c.Stream(http.StatusOK, echo.MIMETextPlainCharsetUTF8, stream)Encountered exception during execution: IncompleteRead(56825 bytes read)
Traceback (most recent call last):
File "/usr/lib/python3.12/http/client.py", line 584, in _get_chunk_left
chunk_left = self._read_next_chunk_size()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/http/client.py", line 551, in _read_next_chunk_size
return int(line, 16)
^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 16: b''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.12/http/client.py", line 600, in _read_chunked
while (chunk_left := self._get_chunk_left()) is not None:
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/http/client.py", line 586, in _get_chunk_left
raise IncompleteRead(b'')
http.client.IncompleteRead: IncompleteRead(0 bytes read)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/ubuntu/venv/lib/python3.12/site-packages/prefect/flow_engine.py", line 989, in run_context
yield self
File "/home/ubuntu/venv/lib/python3.12/site-packages/prefect/flow_engine.py", line 1634, in run_flow_sync
engine.call_flow_fn()
File "/home/ubuntu/venv/lib/python3.12/site-packages/prefect/flow_engine.py", line 1009, in call_flow_fn
result = call_with_parameters(self.flow.fn, self.parameters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/venv/lib/python3.12/site-packages/prefect/utilities/callables.py", line 210, in call_with_parameters
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/tmp/tmpvnd0577jprefect/prefect-scripts-master/flows/data/sync_stock_config_and_log.py", line 80, in main
_get_config_and_log(client, exchange, strategies, day)
File "/tmp/tmpvnd0577jprefect/prefect-scripts-master/flows/data/sync_stock_config_and_log.py", line 43, in _get_config_and_log
shutil.copyfileobj(stream, f)
File "/usr/lib/python3.12/shutil.py", line 203, in copyfileobj
while buf := fsrc_read(length):
^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/http/client.py", line 478, in read
return self._read_chunked(amt)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/http/client.py", line 612, in _read_chunked
raise IncompleteRead(b''.join(value)) from exc
http.client.IncompleteRead: IncompleteRead(56825 bytes read)
never happened in echo v4.
it seems echo close connection too early
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
aldas commentedon Mar 19, 2026
if you add recovery middleware - does it change?
comphilip commentedon Mar 19, 2026
with
middleware.RequestLogger()but nomiddleware.Recover(), got error logaldas commentedon Mar 19, 2026
but
write tcp 10.42.0.222:80->10.42.2.0:44176: i/o timeoutseems more like the Go HTTP server that Echo uses can not send the response to the connected client.And you say that at the other end (Client side) you see incorrectly closed connections.
This seems to indicate that some proxy between the client and HTTP server is closing the connection or there are network problems temporarly.
comphilip commentedon Mar 19, 2026
10.42.0.222:80->10.42.2.0:44176,10.42.0.222:80is echo service k8s pod address,10.42.2.0:44176is traefik proxy pod addressclient <---> traefik proxy <---> echo service, all of them in same local network (same data rack), network speed is 10G, wonder why write tcp timeout
aldas commentedon Mar 19, 2026
maybe there are some reconfigurations done in k8 network or traefik proxy is being redeployed/reloaded? Or another theory - it could happen when the client has bad connection - something like poor wifi connection.
edit: I forgot that everything is in the same rack.
aldas commentedon Mar 19, 2026
are you using only CORS, RequestLogger, Prometheus middlewares? If you look inside debugger at
c.Response()- how manyhttp.ResponseWriterit is wrapping?comphilip commentedon Mar 19, 2026
for a simple static file service, only
echo v5 on 2026-03-17 on business idle time window, no other system component changed: traefik, kubernetes and so on.
then issues happened since 2026-03-18
aldas commentedon Mar 19, 2026
Well.
v4has hack for listenerKeepAlive. This should not be the for a long time, as Go standard library did some changes related to that in ~1.10 but to be use you can try to deploy custom http server that creates these same listener asv4does.aldas commentedon Mar 19, 2026
note to self:
echo.StartConfigshould have way to use custom Listeners.relates to #1942
comphilip commentedon Mar 19, 2026
I can reproduce the error in localhost, just echo web server and curl directly.
curl --limit-rate 1M -o /dev/null http://localhost:8000/package/big.logenvironment: Ubuntu 24.04.3 LTS"
echo log
curl
curl --limit-rate 1M -o /dev/null http://localhost:8000/big.log % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 4 992M 4 39.8M 0 0 1024k 0 0:16:31 0:00:39 0:15:52 1007k curl: (18) transfer closed with 998498709 bytes remaining to readcomphilip commentedon Mar 19, 2026
with github copilt's help, I need to override WriteTimeout to zero
Thanks #2883 , Also #1953 , there is no error log even though the connection is closed by timeout, hard to troubleshooting
aldas commentedon Mar 20, 2026
@comphilip if this problems reappears or did not go away, let me know. I am not convinced that
WriteTimeout=0is here the reason whyv4worked andv5not.Docs say
It could help maybe with streaming then there are no messages to the client for some time.
comphilip commentedon Mar 20, 2026
@aldas problems gone away after
WriteTimeout=0aldas commentedon Mar 20, 2026
ok, but I think the keepalive is probably the issue here then.
WriteTimeoutis not changed fromv4tov5but keepalive part was.comphilip commentedon Mar 20, 2026
@aldas I doubt that it maybe not keepalive issue for my small reproduce issue sample code: #2918 (comment)
aldas commentedon Mar 31, 2026
@comphilip we had similar issue related to SSE and I have decided that
Startmethods should not sethttp.Server.WriteTimeout = 30 time.Secondany more. This will be released soon.I do not know what brain fart I had but I did not connect that we did not set that field in
v4andv5we do.