This repository was archived by the owner on Jan 7, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Rename vars NODE_RED -> NODERED; Disconnect hooks after Node is closed #92
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| { | ||
| "instanceId": "85440fa479689bf6" | ||
| "instanceId": "85440fa479689bf6", | ||
| "telemetryEnabled": false | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| FROM nodered/node-red:4.0.8-22 | ||
| FROM nodered/node-red:4.1.1-22 | ||
|
|
||
| # package | ||
| USER root | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,16 +28,16 @@ module.exports = function (RED) { | |
| options['workerId'] = this.workername; | ||
| } | ||
|
|
||
| if (!options['lockDuration'] && process.env.NODE_RED_ETW_LOCK_DURATION) { | ||
| options['lockDuration'] = parseInt(process.env.NODE_RED_ETW_LOCK_DURATION) || undefined; | ||
| if (!options['lockDuration'] && (process.env.NODE_RED_ETW_LOCK_DURATION || process.env.NODERED_ETW_LOCK_DURATION)) { | ||
| options['lockDuration'] = parseInt(process.env.NODE_RED_ETW_LOCK_DURATION || process.env.NODERED_ETW_LOCK_DURATION) || undefined; | ||
| } | ||
|
|
||
| if (!options['longpollingTimeout']) { | ||
| options['longpollingTimeout'] = parseInt(process.env.NODE_RED_ETW_LONGPOLLING_TIMEOUT) || undefined; | ||
| options['longpollingTimeout'] = parseInt(process.env.NODE_RED_ETW_LONGPOLLING_TIMEOUT || process.env.NODERED_ETW_LONGPOLLING_TIMEOUT) || undefined; | ||
|
||
| } | ||
|
|
||
| if (!options['idleTimeout']) { | ||
| options['idleTimeout'] = parseInt(process.env.NODE_RED_ETW_IDLE_TIMEOUT) || undefined; | ||
| options['idleTimeout'] = parseInt(process.env.NODE_RED_ETW_IDLE_TIMEOUT || process.env.NODERED_ETW_IDLE_TIMEOUT) || undefined; | ||
|
||
| } | ||
|
|
||
| node._subscribed = true; | ||
|
|
@@ -164,7 +164,7 @@ module.exports = function (RED) { | |
| } | ||
| }; | ||
|
|
||
| RED.hooks.add('preDeliver', (sendEvent) => { | ||
| const onPreDeliver = (sendEvent) => { | ||
| if (node.isHandling() && node.ownMessage(sendEvent.msg)) { | ||
|
|
||
| const sourceNode = sendEvent?.source?.node; | ||
|
|
@@ -185,14 +185,15 @@ module.exports = function (RED) { | |
|
|
||
| node.traceExecution(debugMsg); | ||
|
|
||
| if (process.env.NODE_RED_ETW_STEP_LOGGING == 'true') { | ||
| if (process.env.NODE_RED_ETW_STEP_LOGGING == 'true' || process.env.NODERED_ETW_STEP_LOGGING == 'true') { | ||
| node._trace = `'${sourceNode.name || sourceNode.type}'->'${destinationNode.name || destinationNode.type}'`; | ||
| node.log(`preDeliver: ${node._trace}`); | ||
| } | ||
| } | ||
| }); | ||
| }; | ||
| RED.hooks.add('preDeliver', onPreDeliver); | ||
|
|
||
| RED.hooks.add('postDeliver', (sendEvent) => { | ||
| const onPostDeliver = (sendEvent) => { | ||
| if (node.isHandling() && node.ownMessage(sendEvent.msg)) { | ||
| const sourceNode = sendEvent?.source?.node; | ||
| const destinationNode = sendEvent?.destination?.node; | ||
|
|
@@ -211,12 +212,13 @@ module.exports = function (RED) { | |
|
|
||
| node.traceExecution(debugMsg); | ||
|
|
||
| if (process.env.NODE_RED_ETW_STEP_LOGGING == 'true') { | ||
| if (process.env.NODE_RED_ETW_STEP_LOGGING == 'true' || process.env.NODERED_ETW_STEP_LOGGING == 'true') { | ||
| node._trace = `'${sourceNode.name || sourceNode.type}'->'${destinationNode.name || destinationNode.type}'`; | ||
| node.log(`postDeliver: ${node._trace}`); | ||
| } | ||
| } | ||
| }); | ||
| }; | ||
| RED.hooks.add('postDeliver', onPostDeliver); | ||
|
|
||
| node.setSubscribedStatus = () => { | ||
| this._subscribed = true; | ||
|
|
@@ -440,7 +442,7 @@ module.exports = function (RED) { | |
| externalTaskWorker.onHeartbeat((event, external_task_id) => { | ||
| node.setSubscribedStatus(); | ||
|
|
||
| if (process.env.NODE_RED_ETW_HEARTBEAT_LOGGING == 'true') { | ||
| if (process.env.NODE_RED_ETW_HEARTBEAT_LOGGING == 'true' || process.env.NODERED_ETW_HEARTBEAT_LOGGING == 'true') { | ||
| if (external_task_id) { | ||
| this.log(`subscription (heartbeat:topic ${node.topic}, ${event} for ${external_task_id}).`); | ||
| } else { | ||
|
|
@@ -460,7 +462,7 @@ module.exports = function (RED) { | |
|
|
||
| node.setUnsubscribedStatus(error); | ||
|
|
||
| if (process.env.NODE_RED_ETW_STOP_IF_FAILED == 'true') { | ||
| if (process.env.NODE_RED_ETW_STOP_IF_FAILED == 'true' || process.env.NODERED_ETW_STOP_IF_FAILED == 'true') { | ||
| // abort the external task MM: waiting for a fix in the client.ts | ||
| externalTaskWorker.abortExternalTaskIfPresent(externalTask.id); | ||
| // mark the external task as finished, cause it is gone | ||
|
|
@@ -486,7 +488,10 @@ module.exports = function (RED) { | |
|
|
||
| node.on('close', () => { | ||
| try { | ||
| RED.hooks.remove('preDeliver', onPreDeliver); | ||
| RED.hooks.remove('postDeliver', onPostDeliver); | ||
| externalTaskWorker.stop(); | ||
| node.log('External Task Worker closed.'); | ||
| } catch { | ||
| node.error('Client close failed', {}); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The environment variable check is duplicated. Store
process.env.NODE_RED_ETW_LOCK_DURATION || process.env.NODERED_ETW_LOCK_DURATIONin a constant to avoid repeating the logic and improve maintainability.