Closed ernst77 closed 3 years ago
Heya, thanks for reporting.
We'll need more info and/or code to debug this further. Can you please create a repository with the command below, commit the code that reproduces the issue and share the repository here? Please make sure that you have the latest version of the Laravel installer in order to run this command. Please also make sure you have both Git & the GitHub CLI tool properly set up.
laravel new bug-report --github="--public"
Please do not amend and create a separate commit with your custom changes. After you've posted the repository, we'll try to reproduce the issue.
Thanks!
Hello,
https://github.com/ErnestStaug/laravel-batches-bug/compare/batch-bug
I've made branch batch-bug
and latest commit has all the info you need.
Just access routes /create
and /delete
you will see the same message in Horizon batches list as I've mentioned above.
It seems like its not jobs fault but the Bus
then
pipe in which you pass model who is deleted afterwards. I understand why it fails, but because we do not need this information in batch list on Horizon it should still show the the batch list even if the models are deleted by user.
Thanks @ErnestStaug, that was helpful.
I've traced this issue down to this line: https://github.com/laravel/framework/blob/8.x/src/Illuminate/Bus/DatabaseBatchRepository.php#L322
What happens is that the serialized closure is attempted to be unserialized and the models are attempted to be restored. When a model has already been deleted it'll throw the ModelNotFoundException
.
I personally believe this is more a design issue where it's best to pass the model identifier instead of the entire model to the closure since you can't know if it exists or not. And then attempt to retrieve it inside the then
closure of the batch.
An alternative solution is to add a try/catch around the unserialize
call but that might not not be wanted because you wouldn't be able to populate the actual then
call anymore in the response.
Waiting for @themsaid's input here.
I agree I could change this easily to look for a model with specific ID, but if we allow jobs to have models passed and when they are deleted we don’t proceed them ( https://laravel.com/docs/8.x/queues#ignoring-missing-models) ,I would assume same logic should happen here. But this is rather ‘laravel/framework’ issue then horizon…
On 2021-07-09, Fri at 19:29, Dries Vints @.***> wrote:
Waiting for @themsaid https://github.com/themsaid's input here.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/laravel/horizon/issues/1040#issuecomment-877307950, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEDWTAOXHFSPNESPSMHDO4DTW4PWNANCNFSM5ACKPRQQ .
Hey,
Please share the full stack trace of the exception.
Closing this issue because it's inactive, already solved, old or not relevant anymore. Feel to open up a new issue if you're still experiencing this.
Any updates?, i got the same issue when the one of model was deleted
XHRGEThttp://localhost:8000/horizon/api/batches?before_id=
[HTTP/1.1 404 Not Found 62ms]
message "No query results for model [App\\Models\\Channel]."
No payload for this request
Description:
After model is deleted, batch list is not shown anymore. I get error message
No query results for model ***
It seems that batched jobs is trying to query Model or its relations that has been deleted. I don't see why it is needed as there is no information about models that has been passed to jobs in batches.
Steps To Reproduce:
Create a batched job, where model is passed to it. Delete the model.