mage2tv / magento-cache-clean

A faster drop in replacement for bin/magento cache:clean with file watcher
BSD 3-Clause "New" or "Revised" License
531 stars 63 forks source link

Error: Vector's key for assoc must be a number. #93

Closed rikwillems closed 3 years ago

rikwillems commented 3 years ago

When I press v button or make a change in a layout xml file I'm getting the error below. No clue as to what it means so I'm posting it here.

> cache-clean.js --watch
Release 1.0.39 sponsored by https://www.mage2.tv

Hot-keys for manual cache cleaning:
[c]onfig [b]lock_html [l]ayout [t]ranslate [f]ull_page [v]iew [a]ll

Clean generated code: [G]
Clean integration test sandboxes: [I]
Clean static content areas: [F]rontend [A]dminhtml

Watcher initialized (Ctrl-C to quit)
10:12:41 Cleaning cache type(s) layout full_page
/Users/rikwillems/.composer/vendor/mage2tv/magento-cache-clean/bin/cache-clean.js:209
g.ea=function(a,b,c){a=0;for(var d=c;;)if(a<this.j){var e=of(this,a);c=e.length;a:for(var f=0;;)if(f<c){var h=e[f];d=b.b?b.b(d,h):b.call(null,d,h);if(hd(d)){e=d;break a}f+=1}else{e=d;break a}if(hd(e))return Xb(e);a+=c;d=e}else return d};g.ma=function(a,b,c){if("number"===typeof b)return this.Vb(b,c);throw Error("Vector's key for assoc must be a number.");};
                                                                                                                                                                                                                                                                                                             ^

Error: Vector's key for assoc must be a number.
    at V.g.ma (/Users/rikwillems/.composer/vendor/mage2tv/magento-cache-clean/bin/cache-clean.js:209:308)
    at Function.Bd.f (/Users/rikwillems/.composer/vendor/mage2tv/magento-cache-clean/bin/cache-clean.js:81:60)
    at hk (/Users/rikwillems/.composer/vendor/mage2tv/magento-cache-clean/bin/cache-clean.js:374:52)
    at $l (/Users/rikwillems/.composer/vendor/mage2tv/magento-cache-clean/bin/cache-clean.js:446:116)
    at /Users/rikwillems/.composer/vendor/mage2tv/magento-cache-clean/bin/cache-clean.js:446:430
    at /Users/rikwillems/.composer/vendor/mage2tv/magento-cache-clean/bin/cache-clean.js:321:275
    at V.g.ea (/Users/rikwillems/.composer/vendor/mage2tv/magento-cache-clean/bin/cache-clean.js:209:133)
    at tb (/Users/rikwillems/.composer/vendor/mage2tv/magento-cache-clean/bin/cache-clean.js:102:350)
    at Rg (/Users/rikwillems/.composer/vendor/mage2tv/magento-cache-clean/bin/cache-clean.js:321:238)
    at am (/Users/rikwillems/.composer/vendor/mage2tv/magento-cache-clean/bin/cache-clean.js:446:408)
rikwillems commented 3 years ago

One addition, if I downgrade to 1.0.38 or even 1.0.31 I'm getting the same issue. Maybe a project thing as I didn't have it before and now that I think of it another project doesn't have the issue.

rikwillems commented 3 years ago

Ok found it. I removed the id_prefix from the cache configuration in env.php and this causes the error. If the value is not there Magento calculates it from the full directory path so for local I didn't want it in there.

Vinai commented 3 years ago

Thanks for the issue! The script uses the same algorithm as Magento to calculate the id prefix if it isn't configured. Did you set the id prefix to an empty string in the configuration or did you remove the setting completely?

rikwillems commented 3 years ago

I removed the setting completely. After I added it back the problem was gone.

rikwillems commented 3 years ago

Maybe good to add I don't use Redis locally so this was the only configuration key. I get the remaining array. Removing the entire cache array solves the issue too.


    'cache' => [
        'frontend' => [
            'default' => [
                'id_prefix' => '2de_'
            ],
            'page_cache' => [
                'id_prefix' => '2de_'
            ]
        ],
        'allow_parallel_generation' => false
    ],

Then changed it to this, which gave errors.


    'cache' => [
        'frontend' => [
            'default' => [
            ],
            'page_cache' => [
            ]
        ],
        'allow_parallel_generation' => false
    ],
Vinai commented 3 years ago

I am trying to reproduce the error by removing the id prefix from the env.php configuration but everything still works as expected. Could you please post a copy of your require('app/etc/env.php')['cache']['frontend'] configuration (with passwords changed :))?

EDIT: you already did while I was writing this :D

Vinai commented 3 years ago

Thanks, that helps - I am able to reproduce the issue now.

Vinai commented 3 years ago

Just pushed release 1.0.40 which fixes the error. Thanks for reporting!

rikwillems commented 3 years ago

Fix confirmed, thanks for your quick actions! 👍