mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
added default timeout to function node (#1)
* added default timeout to function node * added unit test to support defaultFunctionTimeout
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
const { log } = require("console");
|
||||
|
||||
module.exports = function(RED) {
|
||||
"use strict";
|
||||
|
||||
@@ -399,6 +401,8 @@ module.exports = function(RED) {
|
||||
if(node.timeout>0){
|
||||
finOpt.timeout = node.timeout;
|
||||
finOpt.breakOnSigint = true;
|
||||
} else if(RED.settings.defaultFunctionTimeout > 0){
|
||||
finOpt.timeout = RED.settings.defaultFunctionTimeout * 1000
|
||||
}
|
||||
}
|
||||
var promise = Promise.resolve();
|
||||
@@ -415,8 +419,15 @@ module.exports = function(RED) {
|
||||
var opts = {};
|
||||
if (node.timeout>0){
|
||||
opts = node.timeoutOptions;
|
||||
} else if(RED.settings.defaultFunctionTimeout > 0){
|
||||
opts.timeout = RED.settings.defaultFunctionTimeout * 1000
|
||||
}
|
||||
try {
|
||||
node.script.runInContext(context,opts);
|
||||
} catch (err) {
|
||||
node.error(err);
|
||||
return done(err);
|
||||
}
|
||||
node.script.runInContext(context,opts);
|
||||
context.results.then(function(results) {
|
||||
sendResults(node,send,msg._msgid,results,false);
|
||||
if (handleNodeDoneCall) {
|
||||
|
||||
Reference in New Issue
Block a user