Giter Club home page Giter Club logo

Comments (8)

ClearScriptLib avatar ClearScriptLib commented on May 18, 2024 1

Version 5.5.3 will include a fix for this.

from clearscript.

ClearScriptLib avatar ClearScriptLib commented on May 18, 2024

Hi @nloewen,

We ran the following C# test code in an attempt to confirm your report:

engine.Script.dump = new Action<dynamic>(arg => {
    Console.WriteLine(arg.message);
    Console.WriteLine(arg.stack);
});

engine.Execute(@"
    dump(new Error('hello'));
    dump({x:1});
");

This code threw no exceptions and produced the expected output:

hello
Error: hello
    at Script Document:2:26
[undefined]
[undefined]

Are you doing something differently? Can you provide a minimal code sample that reproduces the issue?

Thanks!

from clearscript.

BrknRobot avatar BrknRobot commented on May 18, 2024

The following VB.net code produces the error

Imports Microsoft.ClearScript

Public Module Module1

    Sub Main()
        Dim engine = New V8.V8ScriptEngine()

        engine.Script.dump = Sub(arg As Object)
                                 Console.WriteLine(arg.message)
                                 Console.WriteLine(arg.stack)
                             End Sub

        engine.Execute("dump({message:'hello',stack:'trace'});" & _
                       "dump(new Error('world'));")
    End Sub

End Module

from clearscript.

ClearScriptLib avatar ClearScriptLib commented on May 18, 2024

Hi @nloewen,

We've confirmed your report. The key difference between the two cases is that the message and stack properties of JavaScript error objects are not enumerable.

VB.NET and C# behave very differently when dealing with dynamic objects, and VB.NET appears to have some quirks that sometimes block access to non-enumerable JavaScript properties.

Would you mind trying something? If you reverse the order of the two calls to dump, does the test still fail?

Thanks!

from clearscript.

BrknRobot avatar BrknRobot commented on May 18, 2024

This works,

engine.Execute("dump(new Error('world'));" & _
               "dump({message:'hello',stack:'trace'});")

As does this

engine.Execute("dump(new Error('world'));" & _
               "dump({message:'hello',stack:'trace'});" & _
               "dump(new Error('world'));")

Thanks for looking into this issue!

from clearscript.

ClearScriptLib avatar ClearScriptLib commented on May 18, 2024

Fixed in Version 5.5.2.

from clearscript.

BrknRobot avatar BrknRobot commented on May 18, 2024

I've found a case that isn't fixed in 5.5.2

engine.Execute("dump(new Error('test'));" & _
               "dump({message:'test'});")

I would expect the second call to dump to print [undefined] instead of throwing an exception.

from clearscript.

ClearScriptLib avatar ClearScriptLib commented on May 18, 2024

Version 5.5.3 has been posted.

from clearscript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.