Git Product home page Git Product logo

Comments (5)

Frenchy31 avatar Frenchy31 commented on May 25, 2024 1

Hi,
I'm currently facing this issue right now. After some debug, it turns out that this only occurs while working with Tinker.
It appears that the closure's body isn't saved correctly.

I'm using this library to store closures as models attributes, using a "Closure" cast.

No problem encountered handling those SerializableClosure during database seeding, we can clearly see this function section inside the serialized object :
"function";s:60:"function ($arg) { return $arg; }"

But when I manipulate an instance of this model inside Tinker :

>>> $m = MyModel::first();
=> App\Models\MyModel {...}
>>> $m->closure = function (int $a, string $b) { return "$a: $b"; };
<warning>PHP Warning:  file_get_contents(eval()'d code): Failed to open stream: No such file or directory in /var/www/html/vendor/laravel/serializable-closure/src/Support/ReflectionClosure.php on line 805</warning>
=> Closure(int $a, string $b) {#4617 …2}
>>> $m->save();
=> true

the function field of the stored SerializableClosure is empty : "function";s:0:"";
, and cause the error message of this thread issue.

I've retried to update this model inside a test command, and everything works fine.

As mentionned by suhaboncukcu, it is probably due to the way Psy Shell terminal treat or cache these fields, so it is probably a missing feature rather than a bug.

from serializable-closure.

nunomaduro avatar nunomaduro commented on May 25, 2024

@suhaboncukcu The code example you gave, does not contain any code that would cause that issue. Are you able to clone this serialisable project locally, and try to reproduce your issue in test?

from serializable-closure.

nunomaduro avatar nunomaduro commented on May 25, 2024

I will re-open the issue once you answer.

from serializable-closure.

suhaboncukcu avatar suhaboncukcu commented on May 25, 2024

Sorry for the late reply. After further investigation, I found out the reason. For the future searchers; if you're using job_batches, loading a corrupted row on your batch table can fill your logs up with this error due to horizon requests for instance.

What I find strange is that whenever I run the above example on tinker , I'm ending up in the same state. It basically adds a row which can't be unserialized correctly. This could also just about my terminal or zsh so I'm not sure if psy/psysh is causing this problem or not. In any case, package -indeed- doesn't seem to have any problems in regular usage.

from serializable-closure.

mvrska avatar mvrska commented on May 25, 2024

Hi,
I'm experiencing this error, too, although the only way I was able to replicate it was via tinker as @suhaboncukcu mentioned.

bash-5.0$ php artisan tinker
Psy Shell v0.11.1 (PHP 7.4.12 — cli) by Justin Hileman
>>> dispatch(function(){info('yay');})->onQueue('yay');
=> Illuminate\Foundation\Bus\PendingClosureDispatch {#5635}
>>> dispatch(function(){info('yay');})->onQueue('yay');
<warning>ErrorException with message 'file_get_contents(eval()'d code): failed to open stream: No such file or directory'</warning>
>>> dispatch(function(){info('yay');})->onQueue('yay');
=> Illuminate\Foundation\Bus\PendingClosureDispatch {#5674}
>>> dispatch(function(){info('yay');})->onQueue('yay');
<warning>ErrorException with message 'file_get_contents(eval()'d code): failed to open stream: No such file or directory'</warning>

it is weird to me that there is no closer trace

from serializable-closure.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.