Skip to content

beforeSend returning false still emits msg-input via Socket.IO #2046

@Marchal-web

Description

@Marchal-web

Bug Description

When beforeSend returns false, the emit('msg-input:' + widget.id, msg, wNode)
is still called unconditionally, sending false to the frontend via Socket.IO.

The comment in the code already acknowledges msg could be null if the beforeSend errors and returns null but the guard is only applied inside the else block,
not on the final emit.

Expected behavior

If beforeSend returns a falsy value, no msg-input event should be emitted
to the frontend.

Proposed fix

In nodes/config/ui_base.js, replace:

emit('msg-input:' + widget.id, msg, wNode)

with:

if (msg) { emit('msg-input:' + widget.id, msg, wNode) }

Use case

A custom widget that receives high-frequency data and processes it server-side
(e.g. forwarding to a UDP server) without any need to transfer data to the frontend.
Currently the only workaround is to throw an error from onInput, which generates
spurious [warn] messages in the Node-RED log.

Version

  • node-red-dashboard: x.x.x
  • Node-RED: x.x.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions