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

fix: don't flush if the request body hasn't been read entirely #122

Merged
merged 1 commit into from
Dec 13, 2022

Conversation

dunglas
Copy link
Owner

@dunglas dunglas commented Dec 7, 2022

Follows #121. Mitigate golang/go#15527.

@jfcoz
Copy link

jfcoz commented Dec 8, 2022

Hello
I’ve started a POC with wordpress + FrankenPHP : https://github.com/jfcoz/wptest
Uploads are uploaded to a bucket via some wordpress plugins that you can enable :

  • humamade/s3-upload plugin
  • OR
  • ilab-media-cloud plugin

You can run it with docker-compose, or in Kubernetes.

During a media upload, I get the error error while reading the request body:

  • only if it runs behind an nginx ingress controller in Kubernetes
  • AND
  • only with the ilab-media-cloud plugin

Your fix already mitigate the crash I get before, but I’m curious to understand the root cause.

Copy link
Collaborator

@withinboredom withinboredom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What a strange bug... 🤔

@dunglas dunglas merged commit 4332bbe into main Dec 13, 2022
@dunglas dunglas deleted the fix/dont-flush-too-early branch June 26, 2023 19:19
@smortexa
Copy link

@dunglas This issue still exists. During an upload (successful) with Octane, the error while reading the request body log prints.

@dunglas
Copy link
Owner Author

dunglas commented Feb 29, 2024

Thanks for the feedback! Would you been able to provide a reproducer?

@smortexa
Copy link

ASAP. I found that this happens for non-upload requests eventually.

@smortexa
Copy link

I tried to reproduce but I faced this #566 (comment) again I couldn't run FrankenPHP with my Dockerfile in my M1 machine. It seems this issue does not exist in Laravel Sail or non-containerized environment.

@smortexa
Copy link

smortexa commented Mar 1, 2024

@jskorlol
Copy link

I too am having this problem. It seems that request_body is limited to 2MB in size.

There is no problem uploading files less than 2MB, but files larger than 2MB will result in an ERROR error while reading the request body error.

http://:9000 {
	request_body {
		max_size 10MB
	}
}

What I don't know is that it doesn't seem to work even though I applied that option.

@withinboredom
Copy link
Collaborator

withinboredom commented Mar 24, 2024

Hmm, I think it makes sense that we are seeing this error, looking at the code.

  1. It looks like the issue this error condition was designed to solve was actually fixed in go (after over six years of being open!), fairly recently. So this code can probably be deleted and probably doesn't work the same as it once did, now that concurrently reading/writing is possible.
  2. If PHP doesn't request enough bytes (2mb chunks sounds pretty reasonable), it will give this error.

This looks like it might be an easy fix since the underlying go issue might be fixed.

@withinboredom
Copy link
Collaborator

@smortexa I've opened a PR to your reproducer with some dockerfile suggestions. Thank you for making it, as it made verifying the fix much easier.

@withinboredom
Copy link
Collaborator

If you'd want to give this image a go: dunglas/frankenphp-dev:latest-8.3-bookworm to validate it is fixed, that would be epic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants