-
Notifications
You must be signed in to change notification settings - Fork 17
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
node object is always undefined #1
Comments
I resolve the problem patching your code (file-function.js) like this: function sendResults(node,_msgid,msgs) {
if (msgs == null) {
return;
} else if (!util.isArray(msgs)) {
msgs = [msgs];
}
var msgCount = 0;
for (var m=0;m<msgs.length;m++) {
if (msgs[m]) {
if (util.isArray(msgs[m])) {
for (var n=0; n < msgs[m].length; n++) {
msgs[m][n]._msgid = _msgid;
msgCount++;
}
} else {
msgs[m]._msgid = _msgid;
msgCount++;
}
}
}
if (msgCount>0) {
node.send(msgs);
}
}
var sandbox = {
console:console,
util:util,
Buffer:Buffer,
node: node,
__node__: {
log: function() {
node.log.apply(node, arguments);
},
error: function() {
node.error.apply(node, arguments);
},
warn: function() {
node.warn.apply(node, arguments);
},
send: function(id, msgs) {
sendResults(node, id, msgs);
},
on: function() {
node.on.apply(node, arguments);
},
status: function() {
node.status.apply(node, arguments);
}
},
context: {
global:RED.settings.functionGlobalContext || {}
}
}; I injected the node objct in the sandbox to have access from the js script file, and configure send node event to called in asyncronous way. What is your opinion??? |
Same for the context... I don't have access to @masalinas , you seem to know your way around better than I, can you point me in the right direction? [edit] I patched it by adding It's a hack until we hear anything... |
I had the same problems and your hacks helped me. I also added I know this repository has been quite dead but maybe someone has an answer: The asynchronous node.send() solution above doesn't work the same as in the regular function node when I use an array to output the message to more than one output, e.g. Can anybody point me in the right direction where I could try to fix that in the code? It must be somewhere in the |
In the javascript file asociated with your node I have an asyncronous called, so I must use the send fuction of the node object to call the next node, i obtain an error because the node object is undefined always.
This is my code:
The same code is tested inside a function node and the result is ok, but if use your node with the same code the node object is undefined and crash.
Regards.
The text was updated successfully, but these errors were encountered: