mage2tv / magento-cache-clean

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

Buffer.alloc is not a function #25

Closed r-martins closed 5 years ago

r-martins commented 5 years ago

The following error happened after commenting a die() line in a front end controllet execute() method, but it's happening in a regular basis after saving anything.

> a:{if(N.b(".php",Fd(a,Q(a)-4))&&(r(Kh(a))?(b=Buffer.alloc(2048),a=Dh.openSync(a,"r"),Dh.readSync(a,b,0,2048,0),Dh.closeSync(a),b=x.a(b)):b=null,a=C(D(Yf(/^\s*namespace\s+([a-z0-9\\]+)/mi,x.a(b)))),b=C(D(Yf(/^\s*class\s+(\w+)/mi,x.a(b)))),a=r(r(a)?b:a)?["\\",x.a(a),"\\",x.a(b)].join(""):null,a=r(a)?wk(a):null,L(a))){de(Bi,"Removing generated code",ze(", ",Z.b(Jk,a)));a=pg(Nh,a);break a}a=null}return a}return null}
>                                                     ^
> 
> TypeError: Buffer.alloc is not a function
>     at Kk (/Users/martins/www/magenteiro2/vendor/mage2tv/magento-cache-clean/bin/cache-clean.js:420:53)
>     at /Users/martins/www/magenteiro2/vendor/mage2tv/magento-cache-clean/bin/cache-clean.js:421:198
>     at FSWatcher.<anonymous> (/Users/martins/www/magenteiro2/vendor/mage2tv/magento-cache-clean/bin/cache-clean.js:334:138)
>     at emitTwo (events.js:100:13)
>     at FSWatcher.emit (events.js:185:7)
>     at FSEvent.FSWatcher._handle.onchange (fs.js:1300:12)

Video: https://www.youtube.com/watch?v=TfPskiLwy-w

Magento version: 2.3.0

Vinai commented 5 years ago

Interesting, cool issue! Thanks for the report. Are you running on Mac OS? What is the output of running node --version?

Vinai commented 5 years ago

Buffer.alloc is a global object function in node (available in node 8-lts, too). It's been available since node 4. Before that, version 0.12 and older, Buffer.alloc didn't exist.

Not sure how to proceed. What node version are you using?

Vinai commented 5 years ago

I've just released 0.0.29 that checks the node version is 8 or newer on startup. Could you please update your installation to the latest release and try again? Thanks!

r-martins commented 5 years ago

My bad.. Although I have node updated on brew, the one that was being used was installed with some other package manager, and was very old (v. 5.6). It seems that its working very well now. Thank you @Vinai .