vuongxuongminh / laravel-async

Package provide simple way to run code asynchronously for your Laravel application.
MIT License
154 stars 26 forks source link

Interesting issue trying to access cloud while in an async job #40

Closed kirkbushell closed 1 year ago

kirkbushell commented 1 year ago

Been having good success with the package so far - well done!

However, as part of my async job, I want to copy files from local to S3. As soon as I just check for file existence:

if (!Storage::disk('cloud')->exists($destination)) {

I see this error:

[2023-08-02 13:03:41] local.ERROR: fwrite(): Write of 3360 bytes failed with errno=32 Broken pipe {"exception":"[object] (ErrorException(code: 0): fwrite(): Write of 3360 bytes failed with errno=32 Broken pipe at /Users/.../Work/Mine/...-laravel/vendor/spatie/async/src/Runtime/ChildRuntime.php:42)
[stacktrace]
#0 /Users/.../Work/Mine/tcgengine-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(254): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8, 'fwrite(): Write...', '/Users/kirkbush...', 42)
#1 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->Illuminate\\Foundation\\Bootstrap\\{closure}(8, 'fwrite(): Write...', '/Users/...', 42)
#2 /Users/.../Work/Mine/...-laravel/vendor/spatie/async/src/Runtime/ChildRuntime.php(42): fwrite(Resource id #3, 'Tzo0MToiU3BhdGl...')
#3 {main}
"} 

I'm not actually sure how to debug this, because I cannot log or dive any deeper, unfortunately.

Any ideas?

kirkbushell commented 1 year ago

Looking further, it actually happens soon as I call:

Storage::disk('cloud')

Which points to the S3 configuration.

kirkbushell commented 1 year ago

I figured it out. I moved the calls out of the async function and did a test, turns out I didn't have dependencies installed.

I think we need some way of escalating exceptions to the parent process. Currently it only shows the exception capture and flow that you use in the catch block.