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

Bug 7.3.5 regression : Error t.ScriptableDispose is not a function when DisableTypeRestriction is enabled #463

Closed
vbornand opened this issue Dec 10, 2022 · 2 comments
Assignees

Comments

@vbornand
Copy link

Hello,

When I try to execute a for .. of with the 7.3.5 version with DisableTypeRestriction = true, I get the following error:

TypeError: t.ScriptableDispose is not a function
    at V8ScriptEngine [internal]:1:1171 -> Object.defineProperty(this,'EngineInternal',{value:(t=>{let e=t=>t.bind();function o(){return new this(...arguments)}let r=t.isHostObjectKey;delete t.isHostObjectKey;let n=t=>!!t&&!0===t[r],i=Promise,c=Symbol(),a=t.toJson;return delete t.toJson,Object.freeze({commandHolder:{},getCommandResult:e(t=>null==t?t:'function'!=typeof t.hasOwnProperty?'Module'===t[Symbol.toStringTag]?'[module]':'[external]':!0===t[r]?t:'function'!=typeof t.toString?'['+typeof t+']':t.toString()),strictEquals:e((t,e)=>t===e),invokeConstructor:e((t,e)=>{if('function'!=typeof t)throw Error('Function expected');return o.apply(t,Array.from(e))}),invokeMethod:e((t,e,o)=>{if('function'!=typeof e)throw Error('Function expected');return e.apply(t,Array.from(o))}),createPromise:e(function(){return new i(...arguments)}),isPromise:e(t=>t instanceof i),isHostObject:e(n),completePromiseWithResult:e((t,e,o)=>{try{e(t())}catch(r){o(r)}}),completePromise:e((t,e,o)=>{try{t(),e()}catch(r){o(r)}}),throwValue:e(t=>{throw t}),getStackTrace:e(()=>{try{throw Error('[stack trace]')}catch(t){return t.stack}}),toIterator:e(function*(t){try{for(;t.ScriptableMoveNext();)yield t.ScriptableCurrent}finally{t.ScriptableDispose()}}),toAsyncIterator:e(async function*(t){try{for(;await t.ScriptableMoveNextAsync();)yield t.ScriptableCurrent}finally{await t.ScriptableDisposeAsync()}}),checkpoint:e(()=>{let e=t[c];if(e)throw e}),toJson:e((t,e)=>a?JSON.parse(a(t,e)):e)})})(this)});
    at Script:1:12
   at Microsoft.ClearScript.V8.SplitProxy.V8SplitProxyNative.ThrowScheduledException()
   at Microsoft.ClearScript.V8.SplitProxy.V8SplitProxyNative.Invoke(Action`1 action)
   at Microsoft.ClearScript.V8.SplitProxy.V8ContextProxyImpl.InvokeWithLock(Action action)
   at Microsoft.ClearScript.V8.V8ScriptEngine.ScriptInvoke[T](Func`1 func)
   at Microsoft.ClearScript.V8.V8ScriptEngine.Execute(UniqueDocumentInfo documentInfo, String code, Boolean evaluate)
   at Microsoft.ClearScript.ScriptEngine.Execute(DocumentInfo documentInfo, String code)
   at Microsoft.ClearScript.ScriptEngine.Execute(String documentName, Boolean discard, String code)
   at Microsoft.ClearScript.ScriptEngine.Execute(String documentName, String code)
   at Microsoft.ClearScript.ScriptEngine.Execute(String code)
   at TestArray.Program.Main(String[] args)

There is no error with the version 7.3.4 and no error if DisableTypeRestriction is false.

Same behavior with .net 6 and .net 7.

Sample program: (In this case the DisableTypeRestriction is useless, but I need it in my real world software)

using Microsoft.ClearScript.V8;

namespace TestArray;

internal class Program
{
    static void Main(string[] args)
    {
        using (var engine = new V8ScriptEngine())
        {
            engine.DisableTypeRestriction = true;
            engine.AddHostObject("house", new House());
            engine.Execute("for (const vi of house.ValuesInt) { console.log(vi); }");
        }
     }
}

public class House
{
    public House() {
        this.ValuesInt = new List<int> { 1, 2 };
    }

    public List<int> ValuesInt { get; set; }

}

Thanks

@ClearScriptLib
Copy link
Collaborator

Hi @vbornand,

That's a bug; we'll have a fix in the next release, due very soon.

Thanks for reporting it!

@ClearScriptLib ClearScriptLib self-assigned this Dec 12, 2022
ClearScriptLib added a commit that referenced this issue Dec 20, 2022
…disabled (GitHub Issue #463); added DocumentFlags.AwaitDebuggerAndPause (GitHub Discussion #452); added AttributeTargets.Constructor to ScriptUsageAttribute and NoScriptAccessAttribute (GitHub Issue #444); updated API documentation. Tested with V8 10.8.168.24.
@ClearScriptLib
Copy link
Collaborator

Fixed in Version 7.3.6.

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

No branches or pull requests

2 participants