laravel/serializable-closure

Job chain can't serialize named argument in closure (Parsing error)

ConsoleTVs opened this issue · 5 comments

  • Laravel Version: 8.73.2
  • PHP Version: 8.0.7
  • Database Driver & Version: mysql Ver 8.0.22 for osx10.16 on x86_64 (Homebrew)

Description:

The closure fails to serialize with:

syntax error, unexpected token ":", expecting ")" {"userId":7,"exception":"[object] (ParseError(code: 0): syntax error, unexpected token \":\", expecting \")\" at laravel-serializable-closure://fn () => $this->requestUpdate(
    \\App\\Models\\clearCollectionCache: false,
    \\App\\Jobs\\Duda\\RefreshSite: true,
):3)
Bus::chain([
    new CreateSite($this),
    fn () => $this->requestUpdate(
        clearCollectionCache: false,
        refreshSite: true,
    ),
])->dispatch();

Steps To Reproduce:

Just add a closure with a named argument call inside and it will fail to parse. Example above.

Workaround

Remove the named argument:

Bus::chain([
    new CreateSite($this),
    fn () => $this->requestUpdate(false, true),
])->dispatch();

Are you using https://github.com/laravel/serializable-closure ? If not, can you please switch to that and try again?

I was able to reproduce your issue: #29. Going to work on the pull request.

Are you using https://github.com/laravel/serializable-closure ? If not, can you please switch to that and try again?

I think we use the defaults. The error mentions laravel-serializable-closure, so I assume we do use it.

I was able to reproduce your issue: #29. Going to work on the pull request.

Awesome, let me know if you guys need some more details!

Moving this to serialisable closure instead.