multi-tenant: Laravel Vapor SQS queue payload "attempts" missing

Description

When a queued job throws an exception, Laravel Vapor tries to update a vapor-specific attempts key in the payload that seems to have been removed. After contacting the Laravel Vapor team for help, we were told that it is likely that someone has removed the custom keys that https://github.com/laravel/vapor-core adds to jobs. After doing some investigation, there isn’t anything else that might have touched the payload accept this package, so I wanted to find some help if anyone might be able to figure out what might be happening.

Laravel Vapor assigns the payload keys here: https://github.com/laravel/vapor-core/blob/9a486ab614e92c01cbd2d089b01cc0124c8eff0a/src/Queue/VaporQueue.php#L41

This package modifies the payload here: https://github.com/tenancy/multi-tenant/blob/5.x/src/Providers/Tenants/QueueProvider.php#L29

I don’t really know how the createPayloadUsing or the createPayloadArray methods work, so I’m a bit stuck in figuring out where to look.


Actual behavior

When a job throws an exception on an app that’s powered by Laravel Vapor, the job should recognise that it’s failed, but the attempts key in the job payload is missing, possibly due to multi-tenant’s queue provider.

Expected behavior

Additional keys added to a job payload should not be removed.


Information

  • hyn/multi-tenant version: 5.5.0
  • laravel version: 6.2.0
  • database driver and version: MySQL 8.0
  • webserver software and version: Laravel Vapor
  • php version: 7.3? Not sure exact version Vapor is running, but minimum

Error log

vendor/laravel/vapor-core/src/Queue/VaporJob.php:21
Undefined index: attempts

I understand that there currently is no expectation for this package to work with Laravel Vapor, but would love to pick on the community’s brain on how I may potentially resolve this.

Thanks in advance!

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 29 (21 by maintainers)

Commits related to this issue

Most upvoted comments

@jedimdan I too have a project that wont be updated to Laravel 7 anytime soon. In the meantime this is the hack i’ve used implement this fix quickly

in my composer.json i add this to the autoload and then create QueueProvider.php. How this helps you.

"autoload": { "exclude-from-classmap": [ "vendor/hyn/multi-tenant/src/Providers/Tenants/QueueProvider.php" ], "files": [ "app/Overrides/QueueProvider.php" ] }

Sorry, have not quite gotten to it yet, really prioritize the work that needs to be done on T/T.

If someone feels up for it, you can create a PR that aligns the Queue related code with the one in T/T.

I’ll give it a try!

We’ve gotten a fix through T/T, we expect this to also work for this package.

PR incoming this week.

@bradley-r-martin-pt PR merged. Issue closed.

Thank you @jedimdan for the efforts.