SpartnerNL / Laravel-Excel

🚀 Supercharged Excel exports and imports in Laravel
https://laravel-excel.com
MIT License
12.3k stars 1.93k forks source link

[QUESTION]How Do I resolve “Illuminate\Queue\InvalidPayloadException: Unable to JSON encode payload. Error code: 5” #2822

Closed c-myers1 closed 4 years ago

c-myers1 commented 4 years ago

Prerequisites

Versions

Description

Trying out the queue system for a better user upload experience with Laravel-Excel.

.env was been changed from 'sync' to 'database' and migrations run. All the necessary use statements are in place yet the error above persists.

The exact error happens here:

Illuminate\Queue\Queue.php:97
        $payload = json_encode($this->createPayloadArray($job, $queue, $data));
                if (JSON_ERROR_NONE !== json_last_error()) {
                            throw new InvalidPayloadException(

Trying out the queue system for a better user upload experience with Laravel-Excel.

.env was been changed from 'sync' to 'database' and migrations run. All the necessary use statements are in place yet the error above persists.

The exact error happens here:

Illuminate\Queue\Queue.php:97 $payload = json_encode($this->createPayloadArray($job, $queue, $data)); if (JSON_ERROR_NONE !== json_last_error()) { throw new InvalidPayloadException(

If I drop ShouldQueue, the file imports perfectly in-session (large file so long wait period for user.)

I've read many stackoverflow, github etc comments on this but I don't have the technical skills to deep-dive to fix my particular situation (most of them speak of UTF-8 but I don't if that's an issue here; I changed the excel save format to UTF-8 but it didn't fix it.)

Additional Information

I var_dumped and noticed $data is empty, $queue is a string with value "default" and $job is a huge object representing the chunked excel import. Searches indicate fiddling with utf8_encode, mb_convert_encoding and iconv but that would involve changing the framework code (and not clear how it won't mess things up, e.g. in the decoding process.

patrickbrouwers commented 4 years ago

Try looking in your payload (dd() / xdebug) and see what it's trying to serialize. By default our jobs serialize just fine, so it's most likely something on your side. I'm unable to debug it for you.