Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Serialization of 'Closure' is not allowed (httpClient property of EasyPostClient) #333

Open
Justintime50 opened this issue Jan 18, 2024 · 0 comments
Labels
triage Issue is being researched

Comments

@Justintime50
Copy link
Member

Software Version

v7.1.0

Language Version

PHP 8.3, Laravel

Operating System

macOS

What happened?

I have a project that uses easypost-php. When using v6.x everything works fine, but when upgrading to v7 I ran into problems. I'm using Laravel and attempting to store the EasyPostClient in a Laravel session. Once I try to save the client to the session via middleware I'm met with the following error: Serialization of 'Closure' is not allowed. I've determined it's due to the httpClient property of the EasyPostClient object containing a closure. Under normal use this is acceptable but when the Laravel session tries to serialize the EasyPostClient object...

public function handle($request, Closure $next)
{
    // various other middleware code

    $client = new EasyPostClient($apiKey);
    $request->session()->put('client', $client);
}

It cannot do so because that's not possible in PHP.

What was expected?

We should explore potential solutions to the problem where we can retain an instance variable of the httpClient so it's tied to the EasyPostClient so it remains performant but allows for proper serialization so users that need to pass around a client can in all situations.

Sample Code

No response

Relevant logs

No response

@Justintime50 Justintime50 added the triage Issue is being researched label Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Issue is being researched
Projects
None yet
Development

No branches or pull requests

1 participant