FlowFuse / FlowFuse/node-red-dashboard

Event handlers (in custom ui nodes) not receiving widget notifications after socket reconnect

Open
#913 2 comments 0 reactions 0 assignees View on GitHub
priority:high size:L type:bug
Dominant language
HTML
Stars
355
Forks
82
Avg merge
4d 23h
Merged PRs (30d)
24

Description

### Current Behavior

this may be related to [#909](https://github.com/FlowFuse/node-red-dashboard/issues/909).
When the Node-red server is restarted (or after deploy/restart flows in the editor), the connection to all dashboard clients is terminated and then automatically restored. However, after the reconnect, the widget can receive new messages from the server node, but some of the widget notifications to the server node's `onSocket` listener may stop working.
Refreshing the client page solves the issue.

### Expected Behavior

After socket connection restoration all widget-node communication (in both directions) should resume properly.

### Steps To Reproduce

1. Take a clean Dashboard 2.0 ui node, for example `ui-example`
2. Implement a widget-to-node notification mechanism, e.g.:

In widget:
```
this.$socket.emit('myCustomEvent'+this.id, this.id, msg)
```
In server node:
```
onSocket: {
['myCusomEvent'+node.id]: function (conn, id, msg) {console.log("Hello from "+conn)}
```
3. Open 3 clients, verify that they all succeed in sending the above notification to the server node
4. Restart the Node-red server process, or deploy/restart flows in the editor, wait for all clients to reconnect
5. Try again to send notifications from all clients - usually some of them will fail (nothing arriving on server node)

### Environment

- Dashboard version: 1.10.0
- Node-RED version: 3.1.9
- Node.js version: 20.10.0
- npm version: 10.2.3
- Platform/OS: Windows
- Browser: Chrome, Edge

### Have you provided an initial effort estimate for this issue?

I have provided an initial effort estimate

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.