1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

fix scope of results for lists

to close #949 - thanks @echobops
This commit is contained in:
Dave Conway-Jones 2022-09-10 13:20:07 +01:00
parent e4dc3a2bcf
commit 9164fc234c
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
2 changed files with 4 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{ {
"name" : "node-red-node-snmp", "name" : "node-red-node-snmp",
"version" : "1.0.2", "version" : "1.0.3",
"description" : "A Node-RED node that gets and sets SNMP oid values. Supports v1, v2c and v3", "description" : "A Node-RED node that gets and sets SNMP oid values. Supports v1, v2c and v3",
"dependencies" : { "dependencies" : {
"net-snmp" : "^3.8.2" "net-snmp" : "^3.8.2"
@ -26,6 +26,7 @@
{ "name": "Mika Karaila" }, { "name": "Mika Karaila" },
{ "name": "Bryan Malyn" }, { "name": "Bryan Malyn" },
{ "name": "Steve-Mcl" }, { "name": "Steve-Mcl" },
{ "name": "Andres" } { "name": "Andres" },
{ "name": "@echobops" }
] ]
} }

View File

@ -392,6 +392,7 @@ module.exports = function (RED) {
node.on("input", function (msg) { node.on("input", function (msg) {
const oids = node.oids || msg.oid; const oids = node.oids || msg.oid;
const { host, sessionid, user, options } = prepareSnmpOptions(node, msg); const { host, sessionid, user, options } = prepareSnmpOptions(node, msg);
const response = [];
function feedCb(varbinds) { function feedCb(varbinds) {
for (let i = 0; i < varbinds.length; i++) { for (let i = 0; i < varbinds.length; i++) {
if (SNMP.isVarbindError(varbinds[i])) { if (SNMP.isVarbindError(varbinds[i])) {
@ -407,10 +408,6 @@ module.exports = function (RED) {
sess.on("error", function (err) { sess.on("error", function (err) {
node.error(err, msg); node.error(err, msg);
}) })
//move response array & feedCb to inside `node.on("input",` to avoid subsequent
// calls overwriting results from previous operations (each call gets own result/response)
const response = [];
sess.subtree(msg.oid, maxRepetitions, feedCb, function (error) { sess.subtree(msg.oid, maxRepetitions, feedCb, function (error) {
if (error) { if (error) {
node.error(error.toString(), msg); node.error(error.toString(), msg);