Merge pull request #4985 from vasuvanka/dev

Add globalFunctionTimeout
This commit is contained in:
Nick O'Leary
2025-06-06 11:40:19 +01:00
committed by GitHub
3 changed files with 83 additions and 3 deletions

View File

@@ -403,6 +403,8 @@ module.exports = function(RED) {
if(node.timeout>0){
finOpt.timeout = node.timeout;
finOpt.breakOnSigint = true;
} else if (RED.settings.globalFunctionTimeout > 0){
finOpt.timeout = RED.settings.globalFunctionTimeout * 1000
}
}
var promise = Promise.resolve();
@@ -419,8 +421,14 @@ module.exports = function(RED) {
var opts = {};
if (node.timeout>0){
opts = node.timeoutOptions;
} else if (RED.settings. globalFunctionTimeout > 0){
opts.timeout = RED.settings. globalFunctionTimeout * 1000
}
try {
node.script.runInContext(context,opts);
} catch (err) {
return done(err);
}
node.script.runInContext(context,opts);
context.results.then(function(results) {
sendResults(node,send,msg._msgid,results,false);
if (handleNodeDoneCall) {

View File

@@ -490,6 +490,7 @@ module.exports = {
* - fileWorkingDirectory
* - functionGlobalContext
* - functionExternalModules
* - globalFunctionTimeout
* - functionTimeout
* - nodeMessageBufferMaxLength
* - ui (for use with Node-RED Dashboard)
@@ -516,7 +517,19 @@ module.exports = {
/** Allow the Function node to load additional npm modules directly */
functionExternalModules: true,
/** Default timeout, in seconds, for the Function node. 0 means no timeout is applied */
/**
* The default timeout (in seconds) for all Function nodes.
* Individual nodes can set their own timeout value within their configuration.
*/
globalFunctionTimeout: 0,
/**
* Default timeout, in seconds, for the Function node. 0 means no timeout is applied
* This value is applied when the node is first added to the workspace - any changes
* must then be made with the individual node configurations.
* To set a global timeout value, use `globalFunctionTimeout`
*/
functionTimeout: 0,
/** The following property can be used to set predefined values in Global Context.