beyondcode / expose

A beautiful, fully open-source, tunneling service - written in pure PHP
https://expose.dev
MIT License
4.25k stars 262 forks source link

Allowed memory size of.. #140

Closed filippesic closed 4 years ago

filippesic commented 4 years ago

Hi,

I whenever the pages loads images this error happen. I thought it was php memory limit or Homestead limit, but it it's not. I didn't find any info about this error, that's why I posted here. Any help is much appreciated.

expose_error

filipac commented 4 years ago

I also get this bug all the time, if I load simple api endpoint it works, but for a full site it fails after the first page load.

PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 110592 bytes) in phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/laminas/laminas-http/src/Response.php on line 196
PHP Stack trace:
PHP   1. {main}() /Users/filipac/.composer/vendor/beyondcode/expose/builds/expose:0
PHP   2. require() /Users/filipac/.composer/vendor/beyondcode/expose/builds/expose:14
PHP   3. LaravelZero\Framework\Kernel->handle() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/expose:46
PHP   4. LaravelZero\Framework\Kernel->handle() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/laravel-zero/framework/src/Kernel.php:91
PHP   5. Illuminate\Console\Application->run() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/laravel-zero/foundation/src/Illuminate/Foundation/Console/Kernel.php:129
PHP   6. Illuminate\Console\Application->run() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/console/Application.php:93
PHP   7. Illuminate\Console\Application->doRun() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/symfony/console/Application.php:140
PHP   8. Illuminate\Console\Application->doRunCommand() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/symfony/console/Application.php:264
PHP   9. App\Commands\ShareCurrentWorkingDirectoryCommand->run() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/symfony/console/Application.php:911
PHP  10. App\Commands\ShareCurrentWorkingDirectoryCommand->run() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/console/Command.php:121
PHP  11. App\Commands\ShareCurrentWorkingDirectoryCommand->execute() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/symfony/console/Command/Command.php:258
PHP  12. LaravelZero\Framework\Application->call() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/console/Command.php:134
PHP  13. Illuminate\Container\BoundMethod::call() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/container/Container.php:592
PHP  14. Illuminate\Container\BoundMethod::callBoundMethod() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/container/BoundMethod.php:35
PHP  15. Illuminate\Container\Util::unwrapIfClosure() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/container/BoundMethod.php:91
PHP  16. Illuminate\Container\BoundMethod::Illuminate\Container\{closure:phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/container/BoundMethod.php:31-35}() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/container/Util.php:37
PHP  17. call_user_func_array:{phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/container/BoundMethod.php:33}() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/container/BoundMethod.php:33
PHP  18. App\Commands\ShareCurrentWorkingDirectoryCommand->handle() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/container/BoundMethod.php:33
PHP  19. App\Commands\ShareCurrentWorkingDirectoryCommand->handle() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/app/Commands/ShareCurrentWorkingDirectoryCommand.php:20
PHP  20. App\Client\Factory->run() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/app/Commands/ShareCommand.php:38
PHP  21. React\EventLoop\StreamSelectLoop->run() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/app/Client/Factory.php:159
PHP  22. React\EventLoop\StreamSelectLoop->waitForStreamActivity() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/react/event-loop/src/StreamSelectLoop.php:212
PHP  23. React\Stream\DuplexResourceStream->handleData() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/react/event-loop/src/StreamSelectLoop.php:245
PHP  24. React\Stream\DuplexResourceStream->emit() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/react/stream/src/DuplexResourceStream.php:193
PHP  25. React\Stream\Util::React\Stream\{closure:phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/react/stream/src/Util.php:70-72}() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php:123
PHP  26. React\Socket\Connection->emit() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/react/stream/src/Util.php:71
PHP  27. React\HttpClient\Response->handleData() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php:123
PHP  28. React\HttpClient\Response->emit() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/react/http-client/src/Response.php:97
PHP  29. Clue\React\Buzz\Message\ReadableBodyStream->Clue\React\Buzz\Message\{closure:phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/clue/buzz-react/src/Message/ReadableBodyStream.php:28-35}() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php:123
PHP  30. Clue\React\Buzz\Message\ReadableBodyStream->handleEnd() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/clue/buzz-react/src/Message/ReadableBodyStream.php:33
PHP  31. Clue\React\Buzz\Message\ReadableBodyStream->close() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/clue/buzz-react/src/Message/ReadableBodyStream.php:151
PHP  32. Clue\React\Buzz\Message\ReadableBodyStream->emit() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/clue/buzz-react/src/Message/ReadableBodyStream.php:50
PHP  33. App\Client\Http\HttpClient->App\Client\Http\{closure:phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/app/Client/Http/HttpClient.php:104-108}() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php:123
PHP  34. App\Client\Http\HttpClient->logResponse() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/app/Client/Http/HttpClient.php:105
PHP  35. App\Logger\RequestLogger->logResponse() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/app/Client/Http/HttpClient.php:122
PHP  36. Illuminate\Support\Collection->transform() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/app/Logger/RequestLogger.php:57
PHP  37. Illuminate\Support\Collection->map() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/support/Collection.php:1240
PHP  38. array_map() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/support/Collection.php:638
PHP  39. App\Logger\RequestLogger->App\Logger\{closure:phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/app/Logger/RequestLogger.php:47-57}() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/support/Collection.php:638
PHP  40. Laminas\Http\Response::fromString() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/app/Logger/RequestLogger.php:52
PHP  41. explode() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/laminas/laminas-http/src/Response.php:196
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/.box/vendor/composer/ClassLoader.php on line 444
PHP Stack trace:
PHP   1. {main}() /Users/filipac/.composer/vendor/beyondcode/expose/builds/expose:0
PHP   2. require() /Users/filipac/.composer/vendor/beyondcode/expose/builds/expose:14
PHP   3. LaravelZero\Framework\Kernel->handle() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/expose:46
PHP   4. LaravelZero\Framework\Kernel->handle() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/laravel-zero/framework/src/Kernel.php:91
PHP   5. Illuminate\Console\Application->run() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/laravel-zero/foundation/src/Illuminate/Foundation/Console/Kernel.php:129
PHP   6. Illuminate\Console\Application->run() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/console/Application.php:93
PHP   7. Illuminate\Console\Application->doRun() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/symfony/console/Application.php:140
PHP   8. Illuminate\Console\Application->doRunCommand() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/symfony/console/Application.php:264
PHP   9. App\Commands\ShareCurrentWorkingDirectoryCommand->run() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/symfony/console/Application.php:911
PHP  10. App\Commands\ShareCurrentWorkingDirectoryCommand->run() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/console/Command.php:121
PHP  11. App\Commands\ShareCurrentWorkingDirectoryCommand->execute() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/symfony/console/Command/Command.php:258
PHP  12. LaravelZero\Framework\Application->call() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/console/Command.php:134
PHP  13. Illuminate\Container\BoundMethod::call() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/container/Container.php:592
PHP  14. Illuminate\Container\BoundMethod::callBoundMethod() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/container/BoundMethod.php:35
PHP  15. Illuminate\Container\Util::unwrapIfClosure() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/container/BoundMethod.php:91
PHP  16. Illuminate\Container\BoundMethod::Illuminate\Container\{closure:phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/container/BoundMethod.php:31-35}() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/container/Util.php:37
PHP  17. call_user_func_array:{phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/container/BoundMethod.php:33}() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/container/BoundMethod.php:33
PHP  18. App\Commands\ShareCurrentWorkingDirectoryCommand->handle() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/container/BoundMethod.php:33
PHP  19. App\Commands\ShareCurrentWorkingDirectoryCommand->handle() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/app/Commands/ShareCurrentWorkingDirectoryCommand.php:20
PHP  20. App\Client\Factory->run() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/app/Commands/ShareCommand.php:38
PHP  21. React\EventLoop\StreamSelectLoop->run() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/app/Client/Factory.php:159
PHP  22. React\EventLoop\StreamSelectLoop->waitForStreamActivity() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/react/event-loop/src/StreamSelectLoop.php:212
PHP  23. React\Stream\DuplexResourceStream->handleData() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/react/event-loop/src/StreamSelectLoop.php:245
PHP  24. React\Stream\DuplexResourceStream->emit() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/react/stream/src/DuplexResourceStream.php:193
PHP  25. React\Stream\Util::React\Stream\{closure:phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/react/stream/src/Util.php:70-72}() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php:123
PHP  26. React\Socket\Connection->emit() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/react/stream/src/Util.php:71
PHP  27. React\HttpClient\Response->handleData() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php:123
PHP  28. React\HttpClient\Response->emit() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/react/http-client/src/Response.php:97
PHP  29. Clue\React\Buzz\Message\ReadableBodyStream->Clue\React\Buzz\Message\{closure:phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/clue/buzz-react/src/Message/ReadableBodyStream.php:28-35}() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php:123
PHP  30. Clue\React\Buzz\Message\ReadableBodyStream->handleEnd() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/clue/buzz-react/src/Message/ReadableBodyStream.php:33
PHP  31. Clue\React\Buzz\Message\ReadableBodyStream->close() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/clue/buzz-react/src/Message/ReadableBodyStream.php:151
PHP  32. Clue\React\Buzz\Message\ReadableBodyStream->emit() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/clue/buzz-react/src/Message/ReadableBodyStream.php:50
PHP  33. App\Client\Http\HttpClient->App\Client\Http\{closure:phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/app/Client/Http/HttpClient.php:104-108}() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php:123
PHP  34. App\Client\Http\HttpClient->logResponse() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/app/Client/Http/HttpClient.php:105
PHP  35. App\Logger\RequestLogger->logResponse() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/app/Client/Http/HttpClient.php:122
PHP  36. Illuminate\Support\Collection->transform() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/app/Logger/RequestLogger.php:57
PHP  37. Illuminate\Support\Collection->map() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/support/Collection.php:1240
PHP  38. array_map() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/support/Collection.php:638
PHP  39. App\Logger\RequestLogger->App\Logger\{closure:phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/app/Logger/RequestLogger.php:47-57}() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/support/Collection.php:638
PHP  40. Laminas\Http\Response::fromString() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/app/Logger/RequestLogger.php:52
PHP  41. explode() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/laminas/laminas-http/src/Response.php:196
PHP  42. Illuminate\Foundation\Bootstrap\HandleExceptions->handleShutdown() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/laravel-zero/foundation/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:0
PHP  43. Illuminate\Foundation\Bootstrap\HandleExceptions->fatalErrorFromPhpError() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/laravel-zero/foundation/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:130
PHP  44. spl_autoload_call() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/laravel-zero/foundation/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:143
PHP  45. Composer\Autoload\ClassLoader->loadClass() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/vendor/laravel-zero/foundation/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:143
PHP  46. Composer\Autoload\includeFile() phar:///Users/filipac/.composer/vendor/beyondcode/expose/builds/expose/.box/vendor/composer/ClassLoader.php:322
filipac commented 4 years ago

Also I tried to set memory_limit to -1 in a lot of places, php.ini, in vendor code, tried to load with php -d memory_limit=-1 /Users/filipac/.composer/vendor/beyondcode/expose/expose, still the same error all over again.

mpociot commented 4 years ago

Do you have any good way of reproducing this error?

Does it happen with any image that you load, or only with bigger images?

filipac commented 4 years ago

@mpociot trying right now, i can reproduce just with one project so I am trying to see which file does break it.

filipac commented 4 years ago

@mpociot seems it's a 5MB photo that breaks it, I tried to load that directly and it works but refreshing it 4-5 times crashes it again with the same memory leak, so it seems memory is not freed somewhere. While is totally our fault for having a 5MB photo, which I will fix now, I think some other people will encounter it too.

Photo for reference and reproducing: https://www.dropbox.com/s/tq7xzpmjxpm1xjb/people3.jpg?dl=0

filippesic commented 4 years ago

If I understood the error correctly, the given exceeded size is referencing the 128MB limit which seems to be the old PHP memory script limit, which is now, by default, 512MB. No matter how much you give it, it still won't work(2048M in my case because it's safer than -1, tho that's only the limit for PHP 7.4). I think that it's triggered by huge amounts of pictures, like @filipac said, pictures above ~5MB like mine. I had a blade view with about 20-30 native resolution pictures which are all 3-7MB each. I made a thumbnail version of all the pics and now I'm loading that, plus I'm using <img loading=lazy.. to load only pics that show up in the modal, which is probably what solved it actually. Please feel free to correct me about anything because I am a beginner after all.

edit: added more info

filippesic commented 4 years ago

Okay, looks like I solved it. It's kinda strange because the error kept complaining about the 128MB(in bytes), but there was not a single PHP limit that's, by default, 128MB. I tried settings all memory_limits in all available PHP versions inside Homestead and it doesn't work. So there's a couple of folders inside /etc/php/7.4/ so I didn't try the other two folders, cgi and fpm, I only tried cli and it's php.ini. Changing the fpms php.ini didn't change anything, it was already at 512M default, but when I changed cgis php.ini it worked. The limit actually was 128M. I read about the differences of all those folders now, but if anyone wants to add anything to clarify more, feel free.

mpociot commented 4 years ago

Thanks for mentioning this. I'll keep this one open though, as it seems like the client (most likely the dashboard) is leaking some memory, which should be fixed

filippesic commented 4 years ago

You are welcome. Glad I could help. :)

mpociot commented 4 years ago

This is now fixed in master - but as it introduces a breaking change (even though unlikely it affects anyone), this will land in the upcoming version 2.0

In the meantime, you can get rid of this by reducing the amount of maximum logged requests/responses in the configuration file max_logged_requests.

hsmess commented 3 years ago

+1 experiencing this with expose share using the default server Not a big deal as reruning expose share fixes it for another few minutes but would be nice to see v2 to fix this at some point.

Expose is fantastic by the way. :)

xsdaniel commented 3 years ago

Hello there,

This is happening to me as well when creating a tunnel to localhost:3000 :-(

In Stream.php line 94:
Allowed memory size of 134217728 bytes exhausted (tried to allocate 27287520 bytes)
In Request.php line 354:
Allowed memory size of 134217728 bytes exhausted (tried to allocate 17369944 bytes)

Is there any way I can increase the allowed memory size locally?

adamhopkinson commented 3 years ago

I'm having this issue too on v2.0.0.

I've followed the suggestion by @mpociot above to update max_logged_requests in the configuration file, which I've located at ~/.composer/vendor/beyondcode/expose/config/expose.php. This has had no effect.

I've also tried updating the conf value for memory_limit and also edited the file to skip responses by status, content_type etc - all to no effect.

I know that running expose runs the binary in ~/.composer/vendor/bin/expose - does this need rebuilding when the config is changed? This is where my composer knowledge runs short!

adamhopkinson commented 3 years ago

To add, the page that was exhausting the memory had an error so was throwing the built-in Laravel error stack - which obviously has a lot of data.

edalzell commented 3 years ago

I'm getting this in 2.0.2 here:

CleanShot 2021-11-03 at 15 44 00@2x

Happens all the time, on most sites.

Note I'm using a custom domain, both client expose and server are the same version 2.0.2.

simonbowen commented 2 years ago

I am also getting this issue as well, configured all the ini files I can to not have a memory limit.

zoix commented 2 years ago

I don't even know why this issue was closed. Also, don't understand why Beyondcode doesn't reply to the support email or the GitHub issues.

@filippesic - please guys, just reply to the emails if you don't have the time to reply to the issues.

leeovery commented 2 years ago

Also seeing this problem.

mpociot commented 2 years ago

Could you provide a reproducible case for this? I'm using expose pretty much every day and never ran into it before.

leeovery commented 2 years ago

Ill try figure out whats going on and reduce it down to something reproducible.

First thing to note, Im running expose for my api, served via valet, and thats solid. No memory issues at all.

However, the frontend is another story. Thats serving via 'npm run dev` from a nuxt setup. It could be something to do with the watcher running on the node side. It seems to happen when I make a change to the code too. That causes the site to reload and ofc expose then serves the requests. Something in that setup is causing the memory issue.

Ill try dig further.

mpociot commented 2 years ago

Yeah might be interesting to see if the file size is an issue. Usually the memory consumption comes from logging the response.

Could you post a stack trace if the error occurs again?

adampapl commented 2 years ago

I'm proxying react app and json api (so no large requests) and expose is crashing every few minutes. Allowed memory size of 134217728 bytes exhausted (tried to allocate 2147483647 bytes)

I ended up starting it like this while true; do expose share http://0.0.0.0:8000 --domain=XXX --server=eu-1 --subdomain=YYY ; done

to make sure it restarts automatically but it's still pain because proxying becomes very slow before it crashes.

I'm using expose 2.0.2

josegus commented 2 years ago

Same here, it is happening when I try to serve a NextJS app that runs locally, using expose 2.2.0

Is it enough to increase the PHP memory limit ini_set(“memory_limit”, "5000M")?

electronick86 commented 2 years ago

Same for me running expose 2.2.0.


In Request.php line 160:

  Allowed memory size of 134217728 bytes exhausted (tried to allocate 2441444 bytes)  

Never had the problem before but today I tried to import several images into my application (POST requests with one picture of 2-3Mo each). After 10 or 20 request, the error happens.

jreviews commented 2 years ago

Similar issue here also on 2.2.0

[2022-05-15 20:48:37] production.ERROR: Allowed memory size of 134217728 bytes exhausted (tried to allocate 6292832 bytes) {"exception":"[object] (Symfony\Component\ErrorHandler\Error\FatalError(code: 0): Allowed memory size of 134217728 bytes exhausted (tried to allocate 6292832 bytes) at phar:///Users/alejandro/.composer/vendor/beyondcode/expose/builds/expose/vendor/react/stream/src/WritableResourceStream.php:66) [stacktrace]

0 {main}

"}

In WritableResourceStream.php line 66:

jbxonline commented 2 years ago

I'm also getting this...

Looking at my issue and the last few comments I see here, it does appear to be when proxying between a js based app. My app is part Laravel, part React. The Laravel side is working fine, but whenever I visit one of the React pages, this happens. I have changed the memory_limit in the expose.php config file from 128M to 2G and also changed the max_logged_requests to 2. Hasn't helped. Here is the error I get:

PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 22130784 bytes) in phar:///Users/jon/.composer/vendor/beyondcode/expose/builds/expose/vendor/laminas/laminas-http/src/Response.php on line 602
[2022-07-14 10:39:17] production.ERROR: Allowed memory size of 134217728 bytes exhausted (tried to allocate 22130784 bytes) {"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Allowed memory size of 134217728 bytes exhausted (tried to allocate 22130784 bytes) at phar:///Users/jon/.composer/vendor/beyondcode/expose/builds/expose/vendor/laminas/laminas-http/src/Response.php:602)
[stacktrace]
#0 {main}
"} 

@mpociot I'm trialing expose for the company I'm contracting at right now, and this issue will prevent us from using it,, so if you have any upcoming fix or workarounds, it would help massively.

slavatarsyurimi commented 1 year ago

Still an issue here. Expose version 2.6.0.

[2023-03-19 16:30:08] production.ERROR: Allowed memory size of 134217728 bytes exhausted (tried to allocate 3322800 bytes) {"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Allowed memory size of 134217728 bytes exhausted (tried to allocate 3322800 bytes) at phar:///Users/slavas/.composer/vendor/beyondcode/expose/builds/expose/vendor/illuminate/http/Request.php:406)
[stacktrace]
#0 {main}
"} 

I'm having a bit of hard time getting the full stack trace since it doesn't seem to be stored in the Laravel logs and I can't find the corresponding PHP logs yet.

This seems to happen every time when loading a fontawesome font file /fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.woff2?44f8148f80e6c3d60fa6425b0cbb862a which is 150 kB. The files is returned just fine, but afterwords it constantly crashes.

@mpociot any possible ideas? Could the versioned filename be breaking it somehow? Will try to dig a bit further.

stephfh commented 1 year ago

Happens for me in 2.6 as well, when it tries to download minified, production-built compiled JavaScript of the site, so the trail with versionised files could be something (haven't dug in further yet)

ERROR: Allowed memory size of 134217728 bytes exhausted (tried to allocate 21591978 bytes) {"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Allowed memory size of 134217728 bytes exhausted (tried to allocate 21591978 bytes) at [...]/expose/vendor/laminas/laminas-http/src/Response.php:262)
[stacktrace]
#0 {main}
"}
radermacher commented 1 year ago

Happens to me in version 2.6.2 as well. For context, I use 'expose' to share a Valet SSL-secured domain. It always crashes when larger files are requested, such as a video.mp4 with a size of approximately 30MB and embeded with an video-html-tag in a blade-view. Hopefully, this helps to reproduce it for you.

production.ERROR: Allowed memory size of 134217728 bytes exhausted (tried to allocate 102400 bytes) {"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Allowed memory size of 134217728 bytes exhausted (tried to allocate 102400 bytes) at phar:///Users/richard/bin/expose/vendor/laminas/laminas-http/src/Response.php:207)
[stacktrace]
#0 {main}
"}

In Response.php line 207:

  Allowed memory size of 134217728 bytes exhausted (tried to allocate 102400 bytes)

Hope you can fix this soon - thanks in advance 🙏

UPDATE I could fix our issue by updating the config file used by Expose: ~/.expose/config.php I increased memory_limit to 512M and got it working!

As a quick fix, I tried at first to set the value of max_logged_requests to 0 and 1, but this didn't work.

So I couldn't fix it by reducing the maximum number of logged requests/responses, as suggested here: https://github.com/beyondcode/expose/issues/140#issuecomment-711066397