Imported and deployed flow from the "Creating your first flow" tutorial produces "Invalid Date" in debug

As an experiment, I

  • did a fresh install of Node-RED
  • moved my existing $HOME/.node-red directory aside
  • started Node-RED
  • copied the flow at the bottom of the Creating your first flow tutorial
  • imported the flow in Node-RED
  • deployed

When I then clicked on the button of the inject node, the debug view shows "Invalid Date" as message payload.

On a whim (having read about similar fixes), I double-clicked the function node and clicked 'DONE' (without making any changes in the code editor) and deployed again: still the same result, "Invalid Date".

Next, I double-clicked the inject node and clicked 'DONE' (again without making any changes) and deployed again: succes! Now I get the full textual date as debug output:

Later, it occurred to me I could add another debug node and wire it directly to the inject node to see what message payload it was outputting:

The inject node in the mported flow appeared to output a message with an empty string as payload, not a timestamp.
After 'fixing' the inject node, it appeared to output a timestamp as expected.

My setup:

OS: Void Linux (x86_64, rolling release)
Node-RED version: v2.0.6 (installed using npm install -g node-red)

Some questions:

  1. Could this issue be caused by the flow that I copied and imported being for an older version of Node-RED?
  2. I seem to have 'fixed' it by editing some node properties without actually changing anything, wouldn't it be nice if this could be automated somehow?

EDIT: Added a screenshot showing the payload output by the imported, un'fixed' inject node

Out of more curiosity, I backed up my $HOME/.node-red directory before and after my 'fix', and lo and behold, some things changed in flows.json without me changing anything in the properties or code editor (.node-red.orig/flows.json has the untouched imported flow, .node-red.fixed/flows.json contains the 'fixed' flow):

$ diff -u .node-red.orig/flows.json .node-red.fixed/flows.json 
--- .node-red.orig/flows.json	2021-10-14 13:05:10.560336880 +0200
+++ .node-red.fixed/flows.json	2021-10-14 13:07:07.735681196 +0200
@@ -22,11 +22,22 @@
         "type": "inject",
         "z": "da78aa5c497d95d5",
         "name": "",
+        "props": [
+            {
+                "p": "payload"
+            },
+            {
+                "p": "topic",
+                "vt": "str"
+            }
+        ],
         "repeat": "",
+        "crontab": "",
         "once": false,
+        "onceDelay": "",
         "topic": "",
-        "payload": "",
-        "x": 90,
+        "payloadType": "date",
+        "x": 100,
         "y": 60,
         "wires": [
             [
@@ -41,6 +52,10 @@
         "name": "Format timestamp",
         "func": "// Create a Date object from the payload\nvar date = new Date(msg.payload);\n// Change the payload to be a formatted Date string\nmsg.payload = date.toString();\n// Return the message so it can be sent on\nreturn msg;",
         "outputs": 1,
+        "noerr": 0,
+        "initialize": "",
+        "finalize": "",
+        "libs": [],
         "x": 290,
         "y": 60,
         "wires": [

Does this indicate that there was a version mismatch that got corrected somehow between the flow I imported and the Node-RED I'm using?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.