Skip to content

upgrade to v5: curl sometimes reports: curl: (92) HTTP/2 stream 1 was not closed cleanly: INTERNAL_ERROR (err 2) #2918

@comphilip

Description

@comphilip

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions