ami-iit/yarp-openmct

We get "stderr: Ports refresh request not sent!" even when the request is sent successfully

Closed this issue · 2 comments

In server.js, procHandler.requestPortsRefresh() never returns true, even in case of success.

info:Yarp command successfully started...
[OPEN-MCT STATIC SERVER] stderr: Ports refresh request not sent!

Fixed in #164 .

process.send(...) returns a boolean, set to true if the message was sent successfully, and false otherwise. So OpenMctServerHandlerChildProc.prototype.requestPortsRefresh() just needs to return that value.

Also fixed UnhandledPromiseRejectionWarning error due to unhandled Promise rejection in

return this.yarpNameListHdl.run('',onStdout,onStdinf,onStderr).then((resultCode) => {
console.debug(`Yarp port names retrieval completed successfully (${resultCode})`);
return rplyBuffer.toString().split(/\n/).filter((line) => {
return line.startsWith("registration name");
}).map((line) => {
return line.split(' ')[2];
});
});

(node:71178) UnhandledPromiseRejectionWarning: Error: spawn yarp ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:467:16)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:71178) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:71178) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[OPEN-MCT STATIC SERVER] stderr: Debugger listening on ws://127.0.0.1:56478/41eb7164-2760-4838-b41a-b09fcb1d0dfd
For help, see: https://nodejs.org/en/docs/inspector
  • => Added a catch block for handling the yarp name list failure (for instance if we have a mismatch in the Yarp dependency version).
  • => Handled the case where no match is found when looking for regexp port names in
    ConfigHandler.prototype.matchRegexp = function(regexpPortIDs, activeYarpPortNames) {
    let regexpMatchedPortInConfig = JSON.parse(JSON.stringify(this.config.portInConfig));
    regexpPortIDs.forEach((id) => {
    let regexpPattern = new RegExp(regexpMatchedPortInConfig[id].yarpName.match(/^@{(?<thePattern>.+)}$/i).groups.thePattern,"i");
    let matchedPorts = activeYarpPortNames.filter((name) => {
    return (name.match(regexpPattern) !== null);
    });
    if (matchedPorts > 1) {
    console.error('error: Yarp port name regexp has multiple matches, kept the first match.');
    }
    regexpMatchedPortInConfig[id].yarpName = matchedPorts[0];
    });
    return regexpMatchedPortInConfig;
    }

Now, when such failure occurs, we get the error shown below, Yarp Text Logging visualiisation is not available, and the rest of the visualiser features work properly.

Failed running Yarp port names retrieval: Error: spawn yarp ENOENT./n
        returning empty array of ports
Yarp port name regexp @{^\/log\/.*\[YarpJS_WholeBodyDynamics\].*$} does not match any existing ports
Yarp port name regexp @{\[walkingModule\]} does not match any existing ports