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

Storage::download throws memory exhausted error when using Swoole #933

Open
NiroDeveloper opened this issue Jul 24, 2024 · 4 comments
Open

Comments

@NiroDeveloper
Copy link
Contributor

Octane Version

2.6.2

Laravel Version

11.16.0

PHP Version

8.3.6

What server type are you using?

Swoole

Server Version

5.1.2

Database Driver & Version

No response

Description

Before i start, this is not a duplicate to #903, this is about Swoole.
Also large stream responses are fixed with #636, but not this case.

While using Storage::download or Storage::response, laravel is creating a stream response that uses php fpassthru($stream).
Somehow the buffering between fpassthru and ob_start does not work, instead it tries to load the full file into the memory.
This leads to out of memory errors while downloading very big files.

If i replace the fpassthru with a fread-while-loop it is working as expected.

I can basically make a pull request, but need help with the solution...
Is this more a problem in the laravel framework or PHP itself?

Steps To Reproduce

  1. Write a laravel controller that uses Storage::download() to download file with e.g. 1 GB
  2. Call the controller and see the out of memory error
Copy link

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

@francoism90
Copy link

I have the same issue, large file downloads aren't always correctly downloaded.

Any workarounds?

@Shkeats
Copy link

Shkeats commented Aug 19, 2024

@francoism90 @NiroDeveloper Are you running octane in HTTP/2 mode? #873 and the PR #875 could be related if so.

@francoism90
Copy link

@Shkeats I'm running Octane on a nginx proxy.

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

No branches or pull requests

4 participants