Repository navigation
Conversation
The tokens store is only initialised when adminAuth is set, but an auth packet on the comms websocket was still checked against it. The TypeError thrown inside the websocket message handler exited the runtime. An editor left open while adminAuth was removed sends its old token on every reconnect, so the restarted runtime kept crashing. Without adminAuth the connection is already authorised, so the packet is now acknowledged with auth:ok and the editor completes its connection. Fixes node-red#5986
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Proposed changes
Fixes #5986
Without
adminAuth, any{"auth": ...}packet sent to/commsstops Node-RED.Tokens.initonly runs whenadminAuthis set, butcomms.jsstill passed the packet tohandleAuthPacket, andTokens.getthen dereferenced the undefinedstorage. The TypeError is thrown inside the websocket message handler, so the runtime exits. An editor tab left open whileadminAuthis removed sends its old token on every reconnect.Change in
editor-api/lib/editor/comms.js: whenadminAuthis not set, an auth packet is acknowledged with{"auth":"ok"}and not checked. The connection is already active, so this only lets the editor finish connecting. Replyingfailwould send the editor to a login dialog with no prompts, and no reply would leave it never re-subscribing. WithadminAuthset, auth packets are handled as before.New test in
test/unit/@node-red/editor-api/lib/editor/comms_spec.js(default settings, noadminAuth):{"auth":"x"}gets{"auth":"ok"}, then subscribe/publish still work.Before the fix (main 935b8d3, the new test run alone with
-g), it fails withUncaught TypeError: Cannot read properties of undefined (reading 'getSessions').After the fix (Node 22.23.2):
The same 3 tests fail on main without this change (236 passing):
serves icons,returns the default icon for invalid pathsandserves the editor resources. They need the built editor assets.I also ran Node-RED from this branch with the default settings file and sent the command from the issue. Before the fix it exited with the TypeError above. After the fix the client gets
{"auth":"ok"}and Node-RED keeps running.Checklist
npm run testto verify the unit tests passI ran the editor-api unit tests above rather than the full
npm run test, which builds the editor first.AI/LLM disclosure