在 Node-RED 中停止流时抛出错误

Throwing errors with stopping the flow in Node-RED

我有一个非常简单的流程:一个注入节点和两个函数节点。 在第一个函数中,我有以下代码:

node.error("test",msg);
return msg;

第二个:

node.warn("this shouldn't be printed");
return msg;

documentation 说:

If the node encounters an error that should halt the current flow, it should log the event with the this.error function.

但这两条消息都显示在 node-red GUI 的调试面板上,这意味着流程不会停止。 我做错了什么?

该文档是关于创建自定义节点的,它是对作者的说明,说明他们在出现错误的情况下需要做什么,而不是平台将为您做什么。

这些说明并不真正适用于您在函数节点中编写的代码,但如果您要遵循它们,则需要从函数中删除错误情况下的 return msg;

实际上,您会使用测试来决定是在自定义节点中调用 node.send(msg); 还是在函数节点中调用 return msg;