🎉 Node-RED 5.0.9 and 4.1.17 released

Checking the action logs on the docker repo I can see they were rebuilt by @hardillb yesterday. This will have been to pickup OS level fixes for the various security issues that have been doing the rounds the last couple of weeks.

I don't believe they have immediate impact to node-red itself, but we had received a couple questions about these updates to the underlying OS.

1 Like

From my analysis, the rebuild appears to be about fixing CVEs.

Thanks for the reply. I use a Node-RED Docker image that is tagged to a Node-RED and Node.js version, so I wasn't expecting my Docker management software to tell me that there was an update for Node-RED. I didn't see anything on the forums, and just wanted to be sure that this was a legit update with all of the security issues that have been going around lately.

1 Like

There is seems to be bug on Safari 27.2 (22625.2.8.11.9) in combination with MacOS 27.2.1 (26B131) - when clicking a flow tab the editor reloads, making it unusable.

I have asked multiple LLM models to assess where the culprit could be located in the source code, they all seem to hint at the mouse up/down events (this is output from Opus on high reasoning);

Assessment

I traced the complete click path through the source. Here is the conclusion.

The click handler chain

Flow tabs are anchor elements with fragment hrefs, created in packages/node_modules/@node-red/editor-client/src/js/ui/common/tabs.js:756:

var link = $("<a/>",{href:"#"+tab.id, class:"red-ui-tab-label"}).appendTo(li);
The event bindings (tabs.js:880-885) are the key issue. Activation runs on mouseup, but the anchor's default navigation is only cancelled later, on click:
link.on("mousedown", function(evt) { mousedownTab = evt.currentTarget })
link.on("mouseup", onTabClick)                              // activation happens here
link.on("auxclick", function(evt) { evt.preventDefault() })
link.on("click", function(evt) { evt.preventDefault(); })   // default cancelled only here
onTabClick → activateTab → options.onchange(tab) → workspaces.js:354:
window.location.hash = 'flow/'+tab.id;

So in a single click gesture the URL is changed programmatically during mouseup, while the anchor's own default fragment navigation (#<tab.id>) is suppressed only afterward in click.

Why this is the suspect

Two fragment destinations are in play for one gesture — the anchor's #<tab.id> and the programmatic #flow/<tab.id> — and the code relies on event ordering (cancel-on-click-after-activate-on-mouseup) to keep it a same-document navigation. That ordering is exactly the kind of behavior a WebKit update can tighten. This matches your symptom and your suspicion about the click handler.
It also explains why it sticks: if the URL ends up as a bare #<tab.id> instead of #flow/<tab.id>, the restore logic in red.js:301 (/^#(flow|node|group)\/.+$/) no longer matches, so on the next load it falls back to RED.workspaces.show(workspaces[0]) (red.js:347-348), which writes the hash again.

its suggestion for a fix;

Suggested source hardening (upstream)

  1. Cancel the default on mousedown/in onTabClick itself rather than deferring to a later click, so the anchor default can never race activation.
  2. Replace the location.hash write in workspaces.js:354 and :365 with history.replaceState(history.state, "", '#flow/'+tab.id), which avoids fragment-navigation default-action semantics entirely.

The root cause is the fragile pattern where a flow-tab click updates the URL via window.location.hash inside the mouse gesture. I changed it to use history.replaceState, which updates the URL fragment without any navigation semantics, so WebKit can't treat it as a document load.

What I changed


File: packages/node_modules/@node-red/editor-client/src/js/ui/workspaces.js
1. Added a helper (near the top of the module):
function setLocationHash(hash) {
    if (window.history && window.history.replaceState) {
        window.history.replaceState(window.history.state, "", "#" + hash);
    } else {
        window.location.hash = hash;   // fallback for very old browsers
    }
}
2. Replaced the two hash writes in the tab onchange handler:
- window.location.hash = 'flow/'+tab.id; → setLocationHash('flow/'+tab.id);
- window.location.hash = ''; → setLocationHash('');

The existing restore logic in red.js (which reads window.location.hash at load) keeps working, because replaceState still updates the fragment — it just doesn't trigger navigation.

Hi @bakman2

Yes, it is related to modifying the location hash directly; something the latest Safari doesn't like you doing. You can follow macOS 27 Safari doesn't work with Node-RED v5.0.7 · Issue #5965 · node-red/node-red · GitHub for the latest.

Thanks! How can I update NR to this specific fixed version ?

The fix only went in yesterday. It will be in the next maintenance release, due tomorrow.

2 Likes

Any news on a new maintenance release? The official Docker container could use an update with the latest Node.js release.

It is on the radar (and in progress) & will land in the coming days.

1 Like