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

Crash when the nodeset CommercialKitchenEquipment is not found (lacks '.xml' at code) #914

Closed
IagoSRL opened this issue Nov 18, 2020 · 3 comments
Labels

Comments

@IagoSRL
Copy link

IagoSRL commented Nov 18, 2020

Current behavior
When requiring the module node-opcua, a crash happens because cannot find an xml file that comes bundle with it. Error message:
Error: Please make sure that nodeset can be found in node_modules\node-opcua-nodesets\nodesets (I removed the absolute part of the path).

Describe the bug
I checked and the folder exists, so debugged the nodesets and it founds lot of files in the folder, except for Opc.Ua.CommercialKitchenEquipment.NodeSet2, the error is thrown at the line trying lo locate that file.

The JavaScript file is at the node-opcua-nodesets module, exactly at this line in the source code

The source code line is:
const commercialKitchenEquipmentNodeSetFilename = constructNodesetFilename("Opc.Ua.CommercialKitchenEquipment.NodeSet2");

It lacks the ".xml" extension, found in the other lines.

To Reproduce

  • npm i node-opcua
  • node
  • require('node-opcua'); (Inside the node REPL)

Proposed fix:
It seems could get fixed by adding the XML extension at the filename at the commented source code line, but it's still strange to me why sometimes throws and sometimes not.

QUESTION: Why I was able to use the module without getting this error at some use cases, but in others so simple as requiring the module it throws this error?

ANSWER: (I researched a bit more when writting this issue and found, partially, the answer by myself :-) There is a condition at the code that only throws error when there is no argument given to the execution of Nodejs, basically meaning that only throws when requiring the module from the Nodejs REPL. At any other case (like node my-app.js), won't throw an error, it will just try to build the path to the forgotten file in a different way without throwing even if the constructed path doesn't exist.

To be honest, I found this whole behavior confusing (how is locating paths and managing the error/not error), but cannot say if is a thing for another issue or there is a good reason why this is the correct way and expected behavior by anyone else. Please don't take me wrong, I am not questioning the design decission around this, I just wanted to point out what I found just in case is a bug.

Expected behavior
Being able to load node-opcua from the node REPL.

  • (x) my request is related to node-opcua acting as a OPCUA CLIENT

  • ( ) my request is related to node-opcua acting as a OPCUA SERVER

  • ( ) I have installed node-opcua from source ( using git clone)

  • (x) I have installed node-opcua as a package ( using npm install )

  • ( ) I am using an application that uses node-opcua

    • ( ) node-red
    • ( ) other : please specify
  • Device: PC

  • OS version: Windows 10

    • (x) Windows : version : Windows 10
    • ( ) Linux : version : _________
    • ( ) MacOs : version : _________
    • ( ) Raspbian: version : _________
    • ( ) Other : specify :
  • Description of the other OPCUA system I am trying to connect to:

    • Name:_________
    • Version:_________
    • Manufacturer/Software vendor:_________
    • link : https://
  • node-opcua version: : 2.26.0

  • Node:
    node --version = 12.18.4

@erossignon
Copy link
Member

Yes, I spotted too, should be fixed in next version.

@erossignon erossignon added the bug label Nov 20, 2020
@IagoSRL
Copy link
Author

IagoSRL commented Nov 20, 2020

Thanks @erossignon.

@erossignon
Copy link
Member

fixed in node-opcua@2.27.0

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

No branches or pull requests

2 participants