Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node.warn and node.error functions are printing twice on the debug window (Node-RED v2.2.2) #3514

Closed
ramuyk opened this issue Apr 1, 2022 · 29 comments

Comments

@ramuyk
Copy link
Contributor

ramuyk commented Apr 1, 2022

Current Behavior

I have node-red v2.2.2 currently installed in different machines with Ubuntu. And I realized that when I use the functions node.warn('any word') or node.error('any word') once, they will print the message on the debug window twice:

Peek 2022-04-01 01-30

I have an old version of Node-red 1.2.1 installed on one machine and it doesn't happen there. I'm sure it's an issue with version 2.2.2.

Expected Behavior

The expected behavior is printing the message only once when I use the function node.warn once.

Steps To Reproduce

No response

Example flow

[{"id":"884df64fc0706d1a","type":"function","z":"ff922ddb.76cc18","name":"node.error('printing twice')","func":"node.error('printing twice')\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1470,"y":1900,"wires":[["d16a5938e610505c"]]},{"id":"c84f153b25b2ec5b","type":"inject","z":"ff922ddb.76cc18","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1260,"y":1900,"wires":[["884df64fc0706d1a"]]},{"id":"d16a5938e610505c","type":"debug","z":"ff922ddb.76cc18","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1690,"y":1900,"wires":[]},{"id":"53023a7dd1eb74ea","type":"function","z":"ff922ddb.76cc18","name":"node.warn('printing twice')","func":"node.warn('printing twice')\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1470,"y":1960,"wires":[["30bbcdcf40181b6d"]]},{"id":"d59918f0a0e600ef","type":"inject","z":"ff922ddb.76cc18","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1260,"y":1960,"wires":[["53023a7dd1eb74ea"]]},{"id":"30bbcdcf40181b6d","type":"debug","z":"ff922ddb.76cc18","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1690,"y":1960,"wires":[]}]

Environment

  • Node-RED version: 2.2.2
  • Node.js version: 16.13.12
  • npm version: 8.5.5
  • Platform/OS: Ubuntu 20.04
  • Browser: Firefox/Chrome
@ralphwetzel
Copy link
Contributor

ralphwetzel commented Apr 1, 2022

Your flow works correctly on

  • Node-RED version: 2.2.2
  • Node.js version: 14.19.1
  • npm version: 6.14.16
  • Platform/OS: Raspberry Pi OS (5.15.30 / Debian 11)
  • Browser: Chrome & Firefox

@Supergiovane
Copy link

Supergiovane commented Apr 1, 2022

Your flow works correctly on

Node-RED version: 2.2.2
Node.js version: 16.x.x
npm version: 8.x.x
Platform/OS: MacOs and Debian
Browser: Safari

Can you replace the content of your function, with this?
I've added a time tick.
So we can understand if the message is duplicated or it's sent twice.

node.error('printing twice ' + new Date().getTime())
return msg;

@ramuyk
Copy link
Contributor Author

ramuyk commented Apr 1, 2022

Peek 2022-04-01 13-31

It prints the same timestamp... If I try using console.log() it prints the message only once on the console. Also, node.send(msg) works fine. The only problem is with node.warn and node.error.

I've installed node-red with npm and I've recently updated it with the command sudo npm install -g --unsafe-perm node-red

@Supergiovane
Copy link

Supergiovane commented Apr 1, 2022

The msg seems to be duplicated.
Have you restarted nodered, right? If not, please do it and retry.

@ramuyk
Copy link
Contributor Author

ramuyk commented Apr 1, 2022

I did it, I even restarted my machine... I actually have node-red installed on different computers with Ubuntu 20.04 and both of them are duplicating these messages.

Going a little further, even when I edit the file 10-function.js on the system with:

...
node.on("input", function(msg, send, done) {
    node.warn('message')
...

I still get this duplicated message... Even though it doesn't look like it's running the function twice because when I try console.log() instead it prints only once.

@Steve-Mcl
Copy link
Contributor

@rafaelmuynarsk this doesn't happen for me in V2.2.2 either...

image

Do you have another node-red 2.2.2 installation to test this against?

Have you modified any of the base node-red js files at all?

How did you install node-red 2.2.2?

@knolleary
Copy link
Member

I actually have node-red installed on different computers with Ubuntu 20.04 and both of them are duplicating these messages.

How did you create the flows on those two machines? Did you recreate the flows from scratch each time? Or did you copy over the flow file or Import/Export from the editor?

If you copied the flow file, can you open it up in a text editor, search for the Function nodes and check their wires property - they should each have a single entry (the id of the respective Debug nodes).

@ramuyk
Copy link
Contributor Author

ramuyk commented Apr 9, 2022

Sorry about the delay, I ended up finding out that it's a problem with a different node that I made: https://www.npmjs.com/package/node-red-contrib-fast-debug-counter

So this issue is not a problem with Node-RED. My idea was to use the debug node as basis for creating a node that can count messages arriving in it. But it turned out that just copying the debug node was too much and it did stuff that was not supposed to happen.

@ramuyk
Copy link
Contributor Author

ramuyk commented Apr 9, 2022

I've just fixed it by erasing this part of the code:

    DebugNode.logHandler = new events.EventEmitter();
    DebugNode.logHandler.on("log",function(msg) {
        if (msg.level === RED.log.WARN || msg.level === RED.log.ERROR) {
            sendDebug(msg);
        }
    });
    RED.log.addHandler(DebugNode.logHandler);

I'm not sure if I'll still see different bugs because I'm using a copy of the debug node. But by now everything seems to be working fine. Thanks for the responses.

@ramuyk ramuyk closed this as completed Apr 9, 2022
@ramuyk
Copy link
Contributor Author

ramuyk commented Apr 11, 2022

Just as a curiosity, is there any chance of adding a feature like this in the official Debug node? It'd be only an extra checkbox inside it. From my experience with Node-RED, counting the number of messages that are passing on the flow is also a way of debugging what's happening.

Before creating this counter node with the official Debug node my flows used to always have a counter and a debug node connected in the same output. So having both of them in a single node made things more practical for me.

@dceejay
Copy link
Member

dceejay commented Apr 11, 2022

While possibly useful I have not heard of much demand for counting messages as a means of debug. If it were to be implemented it would need a bit more design than just a tickbox. How would it be reset ? for example. Would it just replace the status - or be appended - or is that yet another option, etc...

Certainly we can have the discussion

@ramuyk
Copy link
Contributor Author

ramuyk commented Apr 11, 2022

For me, restarting it every time that something changes on the node makes more sense, something like this:

Peek 2022-04-11 18-08

This way the node counts only the messages that arrived since its last deploy. I don't think that it makes sense to use the node status (32 characters) option from the official Debug node together with a counter. So, in my view it could become something like a list where we choose one or another:

Screenshot_20220411_180710

Counting messages is useful in different situations for me. We could use it in situations like:

  1. Counting the number of messages that a stream of buffers splits my data:

Peek 2022-04-11 18-09

  1. When we have an application that sends requests to Node-RED and the http in or any other network node receives them. The advantage of using a counter to debug is that the value of the counter will persist throughout the days if the node is not redeployed. So, if I have Node-RED running on a server and I open it with my computer's browser I'll be able to have a general idea of what APIs are being used the most. Having a counter integrated with the debug node improves the visualization of flows and helps that the following example will not happen (since I won't have a counter and a debug node coming out from the same point everywhere)

Screenshot_20220411_191443

  1. Both printing a huge number of messages to the Debug window or updating the status of a huge number of messages in a short interval of time is not a very efficient thing to do. Let's say the following example:

speed

Here we have a flow that's passing 10000 messages in an instant and we have two rows:

a. The counter in the first row is a subflow that is updating its status in each message that arrives in it. As we can see, it's slow to update the status of a node at a huge frequency (the same would be true for printing on the debug window).
b. The counter in the second row is this node I've published as a workaround for this issue. Instead of printing all messages, it only prints messages that arrive in an interval of time greater than 100 miliseconds. That means the frontend doesn't need to update all the time and I can only display the last message after it stopped receiving messages. It makes the counter a lot faster and in the context of having it in the official Debug node, I see it as the only way of having some kind of debug in flows that are designed to receive a lot of messages, since printing too fast to the debug window slows down everything.

I understand that for some users not printing the status for each message that arrives could generate some confusion if we want to use the status node to take some action based on the counter status. But considering the difference in speed I still think it's worth it.

@dceejay
Copy link
Member

dceejay commented Apr 12, 2022

Yes - would definitely need to be implemented like your option b) - we need to be wary of overloading the websocket with too many updates. Especially if you have lots of debug nodes (in this mode).
Actually the UI already does have a dropdown if status is selected
image
so yes it could be added as a possible option.

Would you like to propose a Pull Request ?

@dceejay dceejay reopened this Apr 12, 2022
@Steve-Mcl
Copy link
Contributor

If you dont mind, I have some suggestions...

  1. An additional msg property to reset the counter programmatically

    1. something like msg._debugCountReset is sufficiently different from other existing msg.reset messages that might hit the debug node?) (open to debate)
  2. Perhaps an alternative to adding to the typedInput list would be to and a check box ☑️ instead, named something like "Suffix message count"

    1. This way we can still show a payload or other property e.g. "150: xxxxxx"

Last one (controversial)...

  1. Consider adding an output port to the debug when "Output to debug window" is ⬛ unchecked. This way we can have in-line debug nodes that dont cause a msg to be cloned (messages are cloned when a debug node is branched off the middle of a flow)
    1. Will require approval from Nick and Dave of course :)

@dceejay
Copy link
Member

dceejay commented Apr 12, 2022

Hmm

  1. uugh - I'd rather repurpose the button to stop - clear and restart... than invent yet another msg property.

  2. Why ? the dropdown already exists... if we added a check box what is the logic for when to show it or not ? I don't think we want to mix count and text in the status. Let's keep it clean.

  3. Hmm - wouldn't you want the debug in the window as well or at least sometimes... it's more a case of removing the button - and the implications of that... inline debug is def something to consider - but I still think you would want to optionally direct the (now always on) output somewhere...

@knolleary
Copy link
Member

If this is being added, then adding a simple 'message count' option to the status list is more than sufficient.

Resetting the value when the node is restarted is good enough for now. Although I wouldn't lose sleep if it support msg.resetCount as well.

Adding an output is completely out of scope of this discussion.

@dceejay
Copy link
Member

dceejay commented Apr 12, 2022

Ok - @rafaelmuynarsk - we're happy to consider an update to add count as a status option. Would you be up for creating a Pull Request, with just the minimum functionality as suggested ?

@Steve-Mcl
Copy link
Contributor

@dceejay

RE: 1. uugh - I'd rather repurpose the button to stop - clear and restart.

  • How would a debug set to NOT output to debug window be reset if we didnt implement this? (the button is removed when not outputting to debug sidebar)
  • what if a user wanted to disable debug sidebar output but still see the count (i.e. to not be reset)? e.g. long term monitoring (but doesnt need the debug output firing needlessly - but does want the debug output when monitoring closely)
    • I have actually done this on a project that collected data from 300 end devices every 30sec & was losing some of the records. I made my own subflow counter & put them in-line in several places so I could narrow down where messages were being lost.

@Steve-Mcl
Copy link
Contributor

Perhaps a better solution altogether would be a separate msg counter node (could also include statistics etc!)

This could be used in-line (to avoid cloning of large messages).

Leaving the debug to be a debug node?

@dceejay
Copy link
Member

dceejay commented Apr 12, 2022

well there are several counter and speed type nodes already that could be tweaked - and indeed Rafael has also released one to do what he wants... ( node-red-contrib-fast-debug-counter ). This debate is whether to just enhance the existing debug to add this mode or not.

@ramuyk
Copy link
Contributor Author

ramuyk commented Apr 13, 2022

@dceejay Sure, I'd be up for contributing to making these changes. I don't think I'll be able to work on that during the week but surely I can make it next weekend. On the node that I've published, I completely removed the node status option, so I need to change it a little bit before making a PR.

Actually, I'm not familiar with making PRs. I was taking a look on the page https://nodered.org/about/contribute/ here, is it just about creating a new branch derived from the master branch and making the changes on the Debug node? Is there any extra procedure I should be aware of?

@Steve-Mcl Even though having an official node with a counter that also includes some statistics would be nice as well, for me what really makes the difference and solves the problem is having a node that can print on the debug window and count messages at the same time. So probably in my case, I'd still use my published version of the node if the counter and debug nodes were separated on the official nodes from Node-RED :)

@dceejay
Copy link
Member

dceejay commented Apr 13, 2022

Great - as this is a new feature you need to make a new branch derived from the dev branch (not master) - and then yes edit the debug node code. Any problems just ask. (though I will be on vacation this weekend/next week for Easter so I may not respond so quick)

Should be fairly simple to add a new statusType of count - then respond to that in the prepareStatus function - and clear count on close. (as a first pass). And in the html to add a new countType to the typedInput types. ("and then just draw the rest of the horse..." :-) )

@knolleary
Copy link
Member

I'm closing this issue as it was not a NR issue.

If a PR arrives in the next week that adds the count status option, we can consider it for 3.0. Otherwise it will be bumped to 3.1

@ramuyk
Copy link
Contributor Author

ramuyk commented Apr 20, 2022

Hi everyone, sorry about the delay. It's actually taking me some time to figure out one last bug that I don't know how to solve yet. The basic functionality is ok already as the following:

Peek 2022-04-20 02-07

I can explain the details about how I've implemented it in a next message... But now I'd like to ask about the bug. I'm having trouble making the status of the debug permanent in the sidebar as follows:

Peek 2022-04-20 02-16

The logical part is ok since I'm using the variable statusType inside the Javascript code in order to activate the counter and deactivate the other status functionalities. But I didn't manage to make the option visually permanent after selecting it... it always goes back to same as debug output. Probably it's a small detail in the HTML file. Which part of the code and which variables I should be looking at in order to make the selected option permanent in the drop-down menu?

@ralphwetzel
Copy link
Contributor

ralphwetzel commented Apr 20, 2022

Hi!
Difficult to guess without knowing your current code ... but I'd look at this section of the html definition of the standard debug node.

A long shot: You could check especially this section here. It looks like you have to define that.statusVal !== "" - otherwise it falls back to auto.

@Steve-Mcl
Copy link
Contributor

@rafaelmuynarsk - how is your PR going?

If your fork & modifications in a public repo somewhere? If so, I can take a look & help you overcome any issues.

Time is running out to get this into the next release.

@ramuyk
Copy link
Contributor Author

ramuyk commented Apr 23, 2022

Hi everyone,

Sorry about the delay again, this week I've been mostly working with SQL stuff :s

I took the time for finishing the debug node and I made a Pull Request just now. Actually, the only thing that I was missing to make it work was using that.statusVal !== "" as @ralphwetzel said. I still have some final doubts about how it'd be better to implement it in the final version. But let's go to the details on how it's working by now. Basically, it works as follows:

Peek 2022-04-23 18-25

To make it simple, the logic behind the counter is based on this snippet:

let lastTime = new Date().getTime();
let timeout = null;
for (let i = 0; i < 10; i++) {
	if (timeout) { clearTimeout(timeout) }
	timeout = setTimeout(() => console.log('Hello'), 200)
}

Here it's an example in a loop, but the implemented idea is the same with messages. If the time between the actual message and the last message is bigger than 100 milliseconds it will just print the status of the message. Otherwise (if it's shorter than 100 milliseconds), it works as the last snippet... That means I store the id of a setTimeout() function in a global variable and it'll be cleared all the times that it receives messages in an interval shorter than 200 milliseconds. This way it will print only the last message when the timeout is not cleared.

The final code then is like (in the .js file):

if ( node.statusType === "counter" ){
	const differenceOfTime  = ((new Date()).getTime() - node.lastTime);
	node.lastTime = new Date().getTime();
	node.counter++;
	if ( differenceOfTime > 100 ){
		node.status({fill:"blue", shape:"ring", text: node.counter});
	} else {
		if (node.timeout) { clearTimeout(node.timeout) }
		node.timeout = setTimeout(() => {
			node.status({fill:"blue", shape:"ring", text: node.counter});
		}, 200)
	}
}

I've created a new statusType with a counter value on the html file and I use it in the js file in order to differentiate when it's selected. I also had to create three global variables:

this.counter = 0; // it stores the value of the counter
this.lastTime = new Date().getTime(); // it stores the time when the last message arrived
this.timeout = null; // it stores the ID of  the setTimeout() function

There are some final considerations that I think are worth reviewing:

  1. I really just changed that.statusVal !== "" to make it work since my last question. Even though it worked I haven't understood completely why it's working. So I don't know if there'll be bad consequences for this change. From the tests I've made everything seems to be working fine.
  2. All the times I've changed the status of the node I've used the function as node.status({fill:"blue", shape:"ring", text: node.counter}); in a single line. I'm not sure if this style is ok for you guys because I've seen it done differently in the debug node (it declares variables for storing the states in an object and then uses node.status(object)).
  3. On the html code I've declared the label of the message count functionality as hardcoded... So it's something like var counter = { value: "counter", label: "message count", hasValue: false };. I've seen the other labels getting these names from somewhere else with something like RED._("node-red:debug.msgobj"), but I didn't manage to figure out where this object is coming from in the code.
  4. There's one edge case when the node keeps receiving messages in an interval shorter than 100 milliseconds for a long period of time. It'll behave as the following:

Peek 2022-04-23 19-20

Since it doesn't update the status when messages arrive in an interval shorter than 100 milliseconds, it'll wait until the last message to print it. I can see a workaround for this issue using the setInterval() function and keeping it running while there's a setTimeout() activated, just so it would keep printing the status every second for example. But that would make the code a little bit uglier (at least on the way that I thought about implementing it). A simple way of doing it would be having a setInterval with 1 second forever activated, but that doesn't seem like a good solution...

So, this last point is more a question than a review... Is it ok leaving it like it is now? In my day-to-day cases of use that won't be an issue, but for some people it may be. Would it be worth implementing the logic with the setInterval() function even if it complicates a little the logic? Or as a simple solution, would it be ok having a setInterval() running every second forever?

JSON with tests from the GIFs:

[{"id":"2f85f3fadd7e8acc","type":"debug","z":"e31af9f309041c23","name":"debug 1","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"","statusType":"counter","x":1180,"y":440,"wires":[]},{"id":"03da44dac24bcfe4","type":"inject","z":"e31af9f309041c23","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":700,"y":440,"wires":[["17705a66856f885e"]]},{"id":"17705a66856f885e","type":"function","z":"e31af9f309041c23","name":"send 10000 messages","func":"for (let i = 0; i < 10000; i++) {\n\tnode.send(msg)\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":940,"y":440,"wires":[["2f85f3fadd7e8acc"]]},{"id":"4bd7bbc82b575d98","type":"inject","z":"e31af9f309041c23","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":700,"y":480,"wires":[["34290aa5cae9367a"]]},{"id":"34290aa5cae9367a","type":"debug","z":"e31af9f309041c23","name":"debug 1","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":900,"y":480,"wires":[]},{"id":"ba122f37601cf84d","type":"debug","z":"e31af9f309041c23","name":"debug 1","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"","statusType":"counter","x":1420,"y":400,"wires":[]},{"id":"e1f5c70950d06b3d","type":"inject","z":"e31af9f309041c23","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":700,"y":400,"wires":[["702cb1dbbf37646d"]]},{"id":"702cb1dbbf37646d","type":"function","z":"e31af9f309041c23","name":"send 100 messages with an interval of 101 milliseconds each","func":"function sleep(time) {\n  return new Promise(resolve => {\n    setTimeout(() => {\n      resolve();\n    }, time);\n  });\n}\n\nasync function executeAsync(){\n\tfor (let i = 0; i < 100; i++) {\n\t\tawait sleep(101)\n\t\tnode.send(msg)\n\t}\n}\nexecuteAsync()\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1060,"y":400,"wires":[["ba122f37601cf84d"]]},{"id":"04180e32ce72c344","type":"debug","z":"e31af9f309041c23","name":"debug 1","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"","statusType":"counter","x":1400,"y":320,"wires":[]},{"id":"6afb34eecccdde77","type":"inject","z":"e31af9f309041c23","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":700,"y":320,"wires":[["198f872fab6dc739"]]},{"id":"198f872fab6dc739","type":"function","z":"e31af9f309041c23","name":"send 100 messages with an interval of 80 milliseconds each","func":"function sleep(time) {\n  return new Promise(resolve => {\n    setTimeout(() => {\n      resolve();\n    }, time);\n  });\n}\n\nasync function executeAsync(){\n\tfor (let i = 0; i < 100; i++) {\n\t\tawait sleep(80)\n\t\tnode.send(msg)\n\t}\n}\nexecuteAsync()\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1050,"y":320,"wires":[["04180e32ce72c344"]]}]

@ramuyk ramuyk mentioned this issue Apr 23, 2022
@ramuyk
Copy link
Contributor Author

ramuyk commented Apr 24, 2022

The "complicated" way of handling the edge case that I mentioned is actually this code:

if ( node.statusType === "counter" ){
	const differenceOfTime  = ((new Date()).getTime() - node.lastTime);
	node.lastTime = new Date().getTime();
	node.counter++;
	if ( differenceOfTime > 100 ){
		node.intervalActivated = false;
		node.status({fill:"blue", shape:"ring", text: node.counter});
	} else {
		if (node.intervalActivated === false){
			node.intervalID = setInterval(() => {
				node.status({fill:"blue", shape:"ring", text: node.counter})
			}, 500)
		}
		node.intervalActivated = true;
		if (node.timeout) { clearTimeout(node.timeout) }
		node.timeout = setTimeout(() => {
			if (node.intervalID) { clearTimeout(node.intervalID) }
			node.status({fill:"blue", shape:"ring", text: node.counter})
		}, 200)
	}
}

I had to add two more global variables for it: this.intervalActivated and this.intervalID. And then the edge case behaves as the following:

Peek 2022-04-23 23-13

It'll continue displaying the messages every 500 milliseconds. The PR that I sent doesn't work like this... For me, I'm not sure if this is a desired functionality...

@ralphwetzel
Copy link
Contributor

I took the time for finishing the debug node and I made a Pull Request just now. Actually, the only thing that I was missing to make it work was using that.statusVal !== "" as @ralphwetzel said. I still have some final doubts about how it'd be better to implement it in the final version. But let's go to the details on how it's working by now. Basically, it works as follows:

I just took a glance at your implementation regarding this detail:

image

For me, this needs some rework: The given check is a guard to ensure that that.statusVal is always defined ... as this is mandatory for the three other options provided. Thus you have to keep it as it is.
For you PR, I see some alternatives to shortcut this check - that is not necessary for statusType == "counter". One could be to assign a dummy value to that.statusVal at an appropriate place in the code. My preferred solutions yet would be something like this:

if ($(this).is(":checked")) {
    if (that.statusType === "counter") {
        that.statusVal = "";
    }
    else if (!that.hasOwnProperty("statusVal") || that.statusVal === "") {
        var type = $("#node-input-typed-complete").typedInput('type');
        var comp = "payload";
        if (type !== 'full') {
            [...]

An additional note: I would / should have placed this comment into your PR. As there yet seems to be issue with the baselining (I'm convinced @Steve-Mcl can support on this), I was unsure if it survives the probably necessary modifications...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants