Regarding the scope: At the beginning of this block of code I have something like:
v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); v8::Context::Scope context_scope(context); v8::TryCatch try_catch(isolate); Then proceed to get a v8::Local<v8::Function> reference to this function. I did the debugging to check the .val_ value and it stays the same between value calls. I also added a try_catch and I catch no errors on the first call. On subsequent calls I get an exception like: TypeError: "literal_name_of_the_js_function" is not a function. This feels weird since I'm calling this same function handler back to back with no other code in between and no side effects (that I know of). If it works one time, it *should* work another one. The function in turn does a single console.log() statements and that's it. I will try to create minimal reproducible code and post it later. On Friday, April 12, 2019 at 5:57:37 PM UTC+3, Ben Noordhuis wrote: > > On Fri, Apr 12, 2019 at 4:56 PM Ben Noordhuis <in...@bnoordhuis.nl > <javascript:>> wrote: > > > > On Fri, Apr 12, 2019 at 4:32 PM Al Mo <almo...@gmail.com <javascript:>> > wrote: > > > On some place in my code I get a reference to a local v8::Function > like this: > > > > > > v8::Persistent<v8::Value>& VALUE; > > > > > > v8::Local<v8::Function> FUNCTION = > v8::Local<v8::Function>::Cast(VALUE); > > > > > > Then I call it like: > > > > > > FUNCTION->Call(v8::Undefined(this->isolate), 0, NULL); > > > > > > "0" and "NULL" since I don't need args at this moment. > > > > > > For some reason, I can only call it once (the callback gets called > once on my JS code). > > > > > > If I call it more than one time, like: > > > > > > FUNCTION->Call(v8::Undefined(this->isolate), 0, NULL); > > > FUNCTION->Call(v8::Undefined(this->isolate), 0, NULL); > > > FUNCTION->Call(v8::Undefined(this->isolate), 0, NULL); > > > FUNCTION->Call(v8::Undefined(this->isolate), 0, NULL); > > > > > > Only the first calls suceeds, the other ones do not throw an error but > also "do nothing". After this, my stack is corrupted. > > > > > > Is there something I don't know about the calling convention that > could explain this? (Perhaps a function instance is meant to only be called > one?) > > > > > > Or should I dive into my code as I may be the one causing the problem > ... ? > > > > Are you sure FUNCTION is properly rooted in a HandleScope? > > > > Can you reproduce in a debugger and if so, does the FUNCTION.val_ > > field change value between calls? > > Forgot to mention, do you have a TryCatch in your code and do you > check TryCatch::HasCaught() afterwards? > -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.