[bug] Mint HTTP2 causes S3 uploads to fail #978

Closed
opened 2025-09-19 18:12:47 +00:00 by floatingghost · 2 comments

Your setup

From source

Extra details

Fedora

Version

develop

PostgreSQL version

16

What were you trying to do?

Upload an image to s3 via the standard uploader

What did you expect to happen?

No response

What actually happened?

looks like we might need to modify how these uploads work

see: https://hexdocs.pm/mint/Mint.HTTP2.html#request/5-request-body-size

Logs

```
[error] Elixir.Pleroma.Uploaders.S3: {:error, %Mint.HTTPError{reason: {:exceeds_window_size, :request, 65535}, module: Mint.HTTP2}}
[error] Elixir.Pleroma.Upload store (using Pleroma.Uploaders.S3) failed: "S3 Upload failed"
```

Severity

I cannot use it as easily as I'd like

Have you searched for this issue?

  • I have double-checked and have not found this issue mentioned anywhere.
### Your setup From source ### Extra details Fedora ### Version develop ### PostgreSQL version 16 ### What were you trying to do? Upload an image to s3 via the standard uploader ### What did you expect to happen? _No response_ ### What actually happened? looks like we might need to modify how these uploads work see: https://hexdocs.pm/mint/Mint.HTTP2.html#request/5-request-body-size ### Logs ````shell ``` [error] Elixir.Pleroma.Uploaders.S3: {:error, %Mint.HTTPError{reason: {:exceeds_window_size, :request, 65535}, module: Mint.HTTP2}} [error] Elixir.Pleroma.Upload store (using Pleroma.Uploaders.S3) failed: "S3 Upload failed" ``` ```` ### Severity I cannot use it as easily as I'd like ### Have you searched for this issue? - [x] I have double-checked and have not found this issue mentioned anywhere.
Author
Owner

if anyone else runs into this, switching

 :pleroma, :http,
  protocols: [:http1]

will rectify the issue until i can figure out the best way to solve this

if anyone else runs into this, switching ```elixir :pleroma, :http, protocols: [:http1] ``` will rectify the issue until i can figure out the best way to solve this
Owner

So, as the linked Mint docs suggest, if using Mint directly one should use stream and get_window__size to split it into appropriately sized chunks.

We’re using Mint via Tesla via Finch, which does in fact already handle this for us since Finch#158IF using its HTTP2 pool setup, i.e. protocols: [:http2].

As mentioned in the PR enabling protocols: [:http1, :http2] by default, if both HTTP versions are supported Finch currently cannot take full advantage of al HTTP2 features due to its own limitations.
That is, because it still uses the HTTP1 pooling logic for multi-protocol setups and as a result window_size is not taken care of and we’re runing into this Finch bug: Finch#265

Afaict Finch doesn’t expose any way to retrieve MInt’s get_window_size, so there’s no way to work around it on our end, short of forcing protocol: [:http1] for requests with a body :\

If we want to keep using Finch, I’m afraid [:http1, :http2] will only work reliably for body requests if the above bug is solved (which likely though means, Finch got a way of determining the protocol after ALPN negotation and using the most appropriate pool and thus now can take full advantage of HTTP2 features for multi-protocol configartions)

So, as the linked Mint docs suggest, if using Mint directly one should use `stream` and `get_window__size` to split it into appropriately sized chunks. We’re using Mint via Tesla via Finch, which does in fact already handle this for us since [Finch#158](https://github.com/sneako/finch/pull/158) — **IF** using its HTTP2 pool setup, i.e. `protocols: [:http2]`. As mentioned in the PR enabling `protocols: [:http1, :http2]` by default, if both HTTP versions are supported Finch currently cannot take full advantage of al HTTP2 features due to its own limitations. That is, because it still uses the HTTP1 pooling logic for multi-protocol setups and as a result `window_size` is not taken care of and we’re runing into this Finch bug: [Finch#265](https://github.com/sneako/finch/issues/265) Afaict Finch doesn’t expose any way to retrieve MInt’s `get_window_size`, so there’s no way to work around it on our end, short of forcing `protocol: [:http1]` for requests with a body :\ If we want to keep using Finch, I’m afraid `[:http1, :http2]` will only work reliably for body requests if the above bug is solved (which likely though means, Finch got a way of determining the protocol after ALPN negotation and using the most appropriate pool and thus now _can_ take full advantage of HTTP2 features for multi-protocol configartions)
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AkkomaGang/akkoma#978
No description provided.