nacmartin / phpexecjs

Run JavaScript code from PHP
MIT License
146 stars 26 forks source link

PHP-FPM+Nginx #13

Closed FaritSlv closed 3 years ago

FaritSlv commented 3 years ago

Hi, for normal work of php-fpm + nginx + v8js you need to reset the $this->v8 property in the createContext method. Without this action, error 502 occurs constantly, and in the logs WARNING: [pool www] child 55 exited on signal 11 (SIGSEGV - core dumped)

public function createContext($code, $cachename = null) { if ($cachename) { $cacheItem = $this->cache->getItem($cachename); if ($cacheItem->isHit()) { $snapshot = $cacheItem->get(); } else { $snapshot = \V8Js::createSnapshot($code); $cacheItem->set($snapshot); $this->cache->save($cacheItem); } } else { $snapshot = \V8Js::createSnapshot($code); } $this->v8 = null; $this->v8 = new \V8Js('PHP', [], [], true, $snapshot); }

https://github.com/phpv8/v8js/issues/138#issuecomment-96840065

nacmartin commented 3 years ago

Thanks, PR merged.