Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handler wrote more than declared Content-Length #6716

Open
Simbiat opened this issue Nov 29, 2024 · 4 comments
Open

handler wrote more than declared Content-Length #6716

Simbiat opened this issue Nov 29, 2024 · 4 comments
Labels
help wanted 🆘 Extra attention is needed

Comments

@Simbiat
Copy link

Simbiat commented Nov 29, 2024

I am getting periodic errors like

{"level":"error","ts":1732885448.9047446,"msg":"write error","error":"http2: handler wrote more than declared Content-Length"}

in my logs. Tried to debug what's happening, and do not see anything obvious. Attaching debug log (zipped since it's quite big) caddy_bck.zip. It has 2 instances of this error. My best guess would be that it's actually a false-positive, since in both cases there is a failed to copy the response body: http2: stream closed message right after, although not sure if that would even make sense. Definitely not related to specific pages (or types of those), at least not able to replicate this on test, just happens on PROD.

My understanding is that it's not normal, possibly a bug somewhere, but unsure how to catch it exactly. I know there was #38, and I am also using Brotli, Zstd, so maybe something wrong with any of those in similar manner? I am launching FrankenPHP in Docker with this config.Caddy config is here (note it's JSON5, not JSON).

@mholt
Copy link
Member

mholt commented Dec 1, 2024

Thanks for the report. Wow a 18k line config! I'll look at this soon. I appreciate the full details like the logs and config, but due to their size it may take some time. If you can figure out a minimally reproducible case that would make a fix arrive quite speedily.

@Simbiat
Copy link
Author

Simbiat commented Dec 1, 2024

The config may look big, but most of the size is from MIME mappings (would not mind to have an alternative way). There are comments there, so you should be able to strip away unnecessary stuff. Log is a debug one + access log, I enabled it this way specifically to capture the errors an everything around them, so you probably need to focus on what's around "more than declared" messages. Unfortunately, I do not know conditions under which this happens. I just found them in my production log, tried to see if I can link them to something based on what I can get in debug log, but... I do not see anything obvious, besides the stream being closed after those messages, but that may be unrelated. Perhaps logging can be improved, so that we can link these kinds of errors to specific requests? Like... Request ID in logs or something similar?

@mholt mholt added the help wanted 🆘 Extra attention is needed label Dec 4, 2024
@mholt
Copy link
Member

mholt commented Dec 4, 2024

I would start fiddling with "encode" handlers (see if removing them resolves the error, etc) -- and also verify that the proxied backends (PHP pages?) aren't sending more than they declare too.

@Simbiat
Copy link
Author

Simbiat commented Dec 4, 2024

question is - what pages? I tested those that around the errors - no issues. Of course they may be edge-cases, and I need some special conditions to trigger the errors, but I would still need to know where to put some extra logging. Generally, they seem to not be sending more than declared, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted 🆘 Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants