node-opcua / node-opcua

Unlocking the Full Potential of OPC UA with Typescript and NodeJS - http://node-opcua.github.io/
MIT License
1.45k stars 479 forks source link

Bind variable error: : the getter must return a Variant or a StatusCode #1374

Closed AndreasHeine closed 1 week ago

AndreasHeine commented 1 week ago

https://github.com/AndreasHeine/SampleServer-node-opcua/blob/f9b42caad83c2aacf5108490589a8b9b67f3c01b/src/serveraddressspace/serveraddressspace.ts#L300C1-L312C11

        const myVar = namespace.addVariable({
            browseName: 'MyVar',
            componentOf: showcaseAC,
            dataType: DataType.Double,
            value: {
                get: function (this) {
                    return new Variant({
                        value: myValue,
                        dataType: DataType.Double
                })},
            },
            eventSourceOf: showcaseAC,
        })

results in:

11:05:52.486Z :ua_variable_impl              :1617   Bind variable error:   : the getter must return a Variant or a StatusCode
 ...                                                value_check.constructor.name  Variant
11:05:52.493Z :address_space                 :1094  modelChangeTransaction  bindVariable : the value getter function returns a invalid result 
( expecting a Variant or a StatusCode !!!
 LOG:   error: Error:  Creating AddressSpace failed: Error:  bindVariable : the value getter function returns a invalid result ( expecting a Variant or a StatusCode !!!
AndreasHeine commented 1 week ago

@erossignon has something changed in the last versions?

erossignon commented 1 week ago

Probably a module mistmatch; please rebuild your node_modules and ensure node-opcua-* version consistency.

AndreasHeine commented 1 week ago

@erossignon you where right ;) thanks!