JavascriptNet / Javascript.Net

.Net bindings to the V8 JavaScript engine
BSD 2-Clause "Simplified" License
829 stars 150 forks source link

Randomly throws exception for the same code #101

Open dnVanz opened 2 years ago

dnVanz commented 2 years ago

Hi,

I've got the following code

`string code = "function imageUrl(){ if(seasonType===\"summer\"){ return \"https://i.ibb.co/P9Sz25M/summer.jpg\"; } if(seasonType===\"winter\"){ return \"https://cdn.pixabay.com/photo/2018/11/22/12/48/clothing-3831823_1280.jpg\"; } if(seasonType===\"spring\"){ return \"https://cdn.pixabay.com/photo/2016/11/16/03/55/blue-1828094_1280.jpg\"; } }; imageUrl();";

var javascriptContext = new JavascriptContext(); javascriptContext.SetParameter("seasonType", "summer"); var expressionJSResult = javascriptContext.Run(code); javascriptContext.Dispose(); Console.WriteLine(expressionJSResult.ToString());`

My issue is that when the same code is run it works sometimes and sometimes it throws the below exception.

at Noesis.Javascript.CompileScript(Local<v8::Script>* , Char* source_code, Char* resource_name) at Noesis.Javascript.JavascriptContext.Run(String iSourceCode) at Program.<Main>$(String[] args)

Appreciate any help on this. I'm using .Net version 4.8.