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

Using V8js(2.1.0) (with v8 6.4.388.41) on ReactBundle 2.1.0 throw error (while trying snapshooting ?) #29

Open
grimpows opened this issue Feb 5, 2018 · 8 comments

Comments

@grimpows
Copy link

grimpows commented Feb 5, 2018

as title say, i get an error here is the stack trace from php-fpm

[05-Feb-2018 13:25:06] WARNING: [pool www] child 5 said into stderr: "# Fatal error in ../../src/snapshot/startup-serializer.cc, line 125"
php_1 | [05-Feb-2018 13:25:06] WARNING: [pool www] child 5 said into stderr: "# Check failed: 0 == isolate->global_handles()->global_handles_count()."
php_1 | [05-Feb-2018 13:25:06] WARNING: [pool www] child 5 said into stderr: "#"
php_1 | [05-Feb-2018 13:25:06] WARNING: [pool www] child 5 said into stderr: ""
php_1 | [05-Feb-2018 13:25:06] WARNING: [pool www] child 5 said into stderr: "==== C stack trace ==============================="
php_1 | [05-Feb-2018 13:25:06] WARNING: [pool www] child 5 said into stderr: ""
php_1 | [05-Feb-2018 13:25:06] WARNING: [pool www] child 5 said into stderr: " /opt/v8/lib/libv8_libbase.so(v8::base::debug::StackTrace::StackTrace()+0x13) [0x7f4352a2ae53]"
php_1 | [05-Feb-2018 13:25:06] WARNING: [pool www] child 5 said into stderr: " /opt/v8/lib/libv8_libplatform.so(+0xc87b) [0x7f4352a4787b]"
php_1 | [05-Feb-2018 13:25:06] WARNING: [pool www] child 5 said into stderr: " /opt/v8/lib/libv8_libbase.so(V8_Fatal(char const*, int, char const*, ...)+0xdc) [0x7f4352a270ec]"
php_1 | [05-Feb-2018 13:25:06] WARNING: [pool www] child 5 said into stderr: " /opt/v8/lib/libv8.so(+0x8e7c1a) [0x7f434859ac1a]"
php_1 | [05-Feb-2018 13:25:06] WARNING: [pool www] child 5 said into stderr: " /opt/v8/lib/libv8.so(v8::SnapshotCreator::CreateBlob(v8::SnapshotCreator::FunctionCodeHandling)+0x77a) [0x7f4347f6a9ea]"
php_1 | [05-Feb-2018 13:25:06] WARNING: [pool www] child 5 said into stderr: " /opt/v8/lib/libv8.so(v8::V8::CreateSnapshotDataBlob(char const*)+0x12b) [0x7f4347f6b0cb]"
php_1 | [05-Feb-2018 13:25:06] WARNING: [pool www] child 5 said into stderr: " /usr/local/lib/php/extensions/no-debug-non-zts-20170718/v8js.so(+0xcdc7) [0x7f43487d7dc7]"
php_1 | [05-Feb-2018 13:25:06] WARNING: [pool www] child 5 said into stderr: " php-fpm: pool www(execute_ex+0x8008) [0x55cd1230f8f8]"
php_1 | [05-Feb-2018 13:25:06] WARNING: [pool www] child 5 said into stderr: " php-fpm: pool www(zend_execute+0x124) [0x55cd1230ff54]"
php_1 | [05-Feb-2018 13:25:06] WARNING: [pool www] child 5 said into stderr: " php-fpm: pool www(zend_execute_scripts+0xd3) [0x55cd1225f563]"
php_1 | [05-Feb-2018 13:25:06] WARNING: [pool www] child 5 said into stderr: " php-fpm: pool www(php_execute_script+0x2a8) [0x55cd121fab48]"
php_1 | [05-Feb-2018 13:25:06] WARNING: [pool www] child 5 said into stderr: " php-fpm: pool www(+0x14a41a) [0x55cd11ec241a]"
php_1 | [05-Feb-2018 13:25:06] WARNING: [pool www] child 5 said into stderr: " /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1) [0x7f434ff9b2b1]"
php_1 | [05-Feb-2018 13:25:06] WARNING: [pool www] child 5 said into stderr: " php-fpm: pool www(_start+0x2a) [0x55cd11ec325a]"

you can saw the v8 source code who throw the error here https://github.com/v8/v8/blob/6.4.388/src/snapshot/startup-serializer.cc at line 125

note that i revert back my reactBundle version to 0.14.1 and my app now work well with v8js, but note that the react_render_array isnt present in 0.14.1 :(

i also tryed to run the symfony_react_sandbox on sf 4 who also use 2.1.0 and the same error is throw

the symfony_react_sandbox on sf 3 use ReactBundle 0.14.1 and working well

if you have a specific version of V8 for using 2.1.0 plz ignore this issue and describe it on doc 👍

note that i cant really test all v8 version as this take something like an hour to compile my V8js on my docker

@jeremy-richard
Copy link

Hi, there. I'm dealing with the same issue when using Limenius/ReactBundle to do SSR with my Symfony 4 + Create React App.
The problem occurs only with Webpack development build. Everything works fine with the production build.

An exception has been thrown during the rendering of a template ("Warning: V8Js::createSnapshot(): Failed to create V8 heap snapshot. Check $embed_source for errors.").

Here's some info :

  • PHP Version 7.1.13
  • v8js Version | 2.1.0
  • V8 Engine Compiled Version | 6.6.0

The index.js looks like this

import ReactOnRails from 'react-on-rails';
import App from './App';

ReactOnRails.register({ App });

And App.jsx

import React from 'react';

function App() {
  return <h1>Hello, world!</h1>;
}

export default App;

Do you need more info to solve this issue ?

@jeremy-richard
Copy link

As a workaround, how do you force phpexecjs to use node cli instaed of v8js? I can't figure out how to configure this.

@grimpows
Copy link
Author

grimpows commented Feb 7, 2018

as i'm using docker i just use a image without v8js enabled, but you can aslo disable v8js from php extension config, normaly reactRenderer autodectect if v8js is enabled and use node if not (node should be installed) if none are installed phpExecJs throw a error

@Quicksaver
Copy link

For me the problem came from Create-React-App's hot reloading module injection. I fixed it by commenting out this line in config/webpack.config.dev.js in my react project (ejected):

require.resolve('react-dev-utils/webpackHotDevClient'),

I also had issues trying to import css files directly in my react app, through import './index.css';, so had to remove that as well; didn't check if this works in production builds though.

@IkeLutra
Copy link

IkeLutra commented Mar 23, 2018

For reference I had this same issue. I narrowed it down to babel-polyfill I had import "babel-polyfill" in my entrypoint file which must have broken the server side bundle by modifying the globals?

To fix I moved babel-polyfill to the webpack entrypoint so it was only on the client side where it is needed.

Using encore

Encore.addEntry("js/entrypoint", ["babel-polyfill", "./assets/js/entrypoint.js"])

@grimpows
Copy link
Author

grimpows commented Mar 23, 2018

look like remove babel-polyfill from serverside config solved my prob too :)
Thx a lot ^^

@nacmartin could you precise this somewhere on doc or/and maybe remove your babel-polyfill from the symfony react sandbox serverside config ?

in case you dont faced this prob with v8js and babel-polyfill can you tell us wich v8 version you use ? ^^

@makivlach
Copy link

makivlach commented Sep 21, 2018

I've got the same problem and it seems it's not affected by the babel configuration inside webpack. I'll keep digging and keep you updated.

Edit: Oh Okay... didn't get it on first thought. So, the solution really seems to be:
in webpack.config.js change .addEntry('server-bundle', ['babel-polyfill', './assets/js/entryPoint.js']) to .addEntry('server-bundle', './assets/js/entryPoint.js')

@gempir
Copy link

gempir commented Oct 16, 2018

Quick debugging tip: Do node yourgenerated.js and you should either see and error or no output at all (which is want you want).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants