mirror of
https://github.com/node-red/node-red.git
synced 2025-12-27 15:34:26 +01: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:
25
packages/node_modules/node-red/settings.js
vendored
25
packages/node_modules/node-red/settings.js
vendored
@@ -473,6 +473,7 @@ module.exports = {
|
||||
* - fileWorkingDirectory
|
||||
* - functionGlobalContext
|
||||
* - functionExternalModules
|
||||
* - defaultFunctionTimeout
|
||||
* - functionTimeout
|
||||
* - nodeMessageBufferMaxLength
|
||||
* - ui (for use with Node-RED Dashboard)
|
||||
@@ -499,8 +500,30 @@ module.exports = {
|
||||
/** Allow the Function node to load additional npm modules directly */
|
||||
functionExternalModules: true,
|
||||
|
||||
|
||||
/**
|
||||
* Default function timeout (in seconds) for the Function node.
|
||||
* A value of 0 indicates no timeout is applied, meaning the function can run indefinitely.
|
||||
*
|
||||
* The default function timeout is designed to prevent blocking code in function nodes,
|
||||
* which could otherwise lead to a stalled or unresponsive main thread. For example,
|
||||
* the following code would block the event loop indefinitely:
|
||||
*
|
||||
* `while(1) {}`
|
||||
*
|
||||
* By specifying a `defaultFunctionTimeout`, such scenarios can be mitigated,
|
||||
* ensuring that long-running or infinite loops are terminated automatically after
|
||||
* the specified timeout duration.
|
||||
*
|
||||
* Note: If both `defaultFunctionTimeout` and `functionTimeout` are defined in the
|
||||
* settings file, `functionTimeout` takes precedence, providing a more granular
|
||||
* control for individual function nodes.
|
||||
*/
|
||||
|
||||
defaultFunctionTimeout: 5,
|
||||
|
||||
/** Default timeout, in seconds, for the Function node. 0 means no timeout is applied */
|
||||
functionTimeout: 0,
|
||||
functionTimeout: 2,
|
||||
|
||||
/** The following property can be used to set predefined values in Global Context.
|
||||
* This allows extra node modules to be made available with in Function node.
|
||||
|
||||
Reference in New Issue
Block a user