Skip to content

Only connect websocket client if need to - #5533

Merged
knolleary merged 2 commits into
devfrom
only-connect-websocket-client-if-need-to
Apr 30, 2026
Merged

knolleary merged 2 commits into
devfrom
only-connect-websocket-client-if-need-to

Conversation

@dceejay

@dceejay dceejay commented Mar 6, 2026

Copy link
Copy Markdown
Member

to address Issue #5506

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Proposed changes

This PR enhances the web socket node to only connect (when in client mode) the underlying connection if there is actually a node that demands it. IE If you disable all the client nodes on the desktop the underlying config node will not create a connection.

Checklist

  • I have read the contribution guidelines
  • For non-bugfix PRs, I have discussed this change on the forum/slack team.
  • I have run npm run test to verify the unit tests pass
  • I have added suitable unit tests to cover the new/changed functionality

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR changes the websocket client config node behavior so it only establishes the underlying outbound connection when there is an active node that actually uses it, addressing Issue #5506 (client config nodes connecting even when dependent flows are disabled).

Changes:

  • Stop auto-connecting websocket client config nodes on creation; defer connection until a consumer node exists.
  • Trigger client connection when the first websocket in node registers, and when a websocket out node is created.
  • Update existing websocket-client tests to include a consumer node so connection-oriented assertions still run.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/node_modules/@node-red/nodes/core/network/22-websocket.js Defers websocket client connection and adds “connect-on-first-consumer” logic.
test/nodes/core/network/22-websocket_spec.js Adjusts websocket-client tests to ensure a consumer node exists so a connection is initiated.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@knolleary
knolleary merged commit ecf8b56 into dev Apr 30, 2026
8 checks passed
@knolleary
knolleary deleted the only-connect-websocket-client-if-need-to branch April 30, 2026 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants