[Bug]: Defaults not used when running queue:work
Propaganistas opened this issue · 10 comments
Propaganistas commented
What happened?
I've set defaults for the PdfBuilder in a service provider's boot()
method as described in the docs.
When a PDF gets generated in a queued job:
- the defaults are applied when powering the queue using
queue:listen
- the defaults are NOT applied when powering the queue using
queue:work
How to reproduce the bug
- Create a fresh Laravel application (I'm on 10.x).
- Change queue connection to
database
and publish the jobs table - Set defaults in AppServiceProvider
boot()
(e.g.Pdf::default()->margin(0.4, 0.4, 0.4, 0.4, Unit::Inch)
- Create a job that generates a PDF ( e.g.
Pdf::view('welcome')->save('somewhere')
) - Run
queue:work
- Enqueue the job using Tinker (or otherwise) and check result
Or temporarily add a dump statement in PdfBuilder's view()
method to check the margins
property and return early.
You'll notice the margins are set when running queue:listen
but remain null
when running queue:work
.
Package Version
1.4.0
PHP Version
8.3.3
Laravel Version
10.48.4
freekmurze commented
Is there some way to add a test for this?
Propaganistas commented
Is there some way to add a test for this?
Not sure. I think you could borrow ideas from framework tests?
https://github.com/laravel/framework/blob/10.x/tests/Queue/QueueWorkerTest.php