Node-RED v0.19.4 3 minute delay during startup on windows

On windows I experience long startup delays of up to 3 minutes between Node-RED start and "Loading palette nodes" log message.

Welcome to Node-RED

8 Oct. 16:07:02 - [info] Node-RED version v0.19.4
8 Oct. 16:07:02 - [info] Node.js version: v8.11.4
8 Oct. 16:07:02 - [info] Windows_NT 6.1.7601 x64 LE

8 Oct. 16:10:11 - [info] Loading palette nodes
....

My setup: Node-RED user independent install to c:\ProgramData\npmglobal and c:\ProgramData.node-red
Startup via PM2-windows-service, but delay also accurs if Node-RED ist started manually on CLI

Any suggestions?

Lace

I have same experiences with one of my PC-s. Tried to find reasons but no luck for now. Sometimes the startup time is even more than minute. And that machine is much more powerfull than my others. I guess the corporate security settings might have some affections but that sort of things are unreachable for me in all means. So I accepted that slow start on that PC as others behave well enought.

There must be a way to debug on which task Node-RED hangs

in services.msc do node-red or pm2 show as "delayed start?"

Just for your reference, for me it takes 14 seconds between start and "Loading pallete nodes", in a fresh start.

Welcome to Node-RED

8 Oct 21:58:32 - [info] Node-RED version: v0.19.1
8 Oct 21:58:32 - [info] Node.js version: v8.11.1
8 Oct 21:58:32 - [info] Windows_NT 10.0.17134 x64 LE
8 Oct 21:58:46 - [info] Loading palette nodes

After a restart it is even faster, only 5 seconds:

8 Oct 22:05:24 - [info] Node-RED version: v0.19.1
8 Oct 22:05:24 - [info] Node.js version: v8.11.1
8 Oct 22:05:24 - [info] Windows_NT 10.0.17134 x64 LE
8 Oct 22:05:25 - [trace] git init: {"version":"2.16.1.windows.1","user":{""}}
8 Oct 22:05:29 - [info] Loading palette nodes

Here you go - not sure how technical you are

Stop Node-red from running through PM2

Run this https://docs.microsoft.com/en-us/sysinternals/downloads/procmon

then fire up Node-red and try to isolate down where it is spending all of its time.

In particular you will be able to filter out other extraneous processes and just drill down into the NR processes to see where the delays are

Craig

With Process Monitor I found:
C:\Users\{username}\AppData\Roaming\npm\node_modules\node-red\node_modules\proxy-addr\node_modules gets result NAME NOT FOUND

Running Node-RED behind corporate proxy. Tried to fix with help of goolge but no luck yet.

Startup times should be less than that of an equivalent setup on a Pi of course - unless you have a lot of other things going on.

Obvious place to start is to monitor disk and CPU activity during startup. I've had a PC in the past with a hybrid hdd/sdd that insisted on pausing every now and again due to a badly concocted disk interface.

Next place I'd look is at any node that relies on the network. Long pauses are often due to TCP timeouts so check if a node is looking for a network resource when it starts up. This might well account for different startup times in different locations - e.g. home vs corporate network.

If general monitoring can't help. Try using a NodeJS debugging monitor. The VScode editor can be configured to do detailed debugging of NodeJS apps and I've written about that previously.

My own PC is used for development and only takes a few seconds to start. I typically don't have a lot of big flows but even when I have, it doesn't take long to start.

This is a delay before Node-RED has loaded the flows - so won't be related to anything your flow is doing.

8 Oct 21:58:32 - [info] Windows_NT 10.0.17134 x64 LE
8 Oct 21:58:46 - [info] Loading palette nodes

The main activity Node-RED is doing between these two log statements is scanning the file system for node-red nodes to load - so is heavily dependent on disk access.

I'm slightly surprised it would take 3 minutes ... that's the sort of speed we'd get on an original Pi with slow SD Card access.

Hey, I experienced a similar issue on some computers in my former company. I'm not sure this is the same reason, but I think i should share my experience just in case...

I found out that the launcher hung in a loop that is in a script located at C:\Program Files\nodejs\npm.cmd

:: Created by npm, please don't edit manually.
@ECHO OFF

SETLOCAL

SET "NODE_EXE=%~dp0\node.exe"
IF NOT EXIST "%NODE_EXE%" (
  SET "NODE_EXE=node"
)

SET "NPM_CLI_JS=%~dp0\node_modules\npm\bin\npm-cli.js"
FOR /F "delims=" %%F IN ('CALL "%NODE_EXE%" "%NPM_CLI_JS%" prefix -g') DO (
  SET "NPM_PREFIX_NPM_CLI_JS=%%F\node_modules\npm\bin\npm-cli.js"
)
IF EXIST "%NPM_PREFIX_NPM_CLI_JS%" (
  SET "NPM_CLI_JS=%NPM_PREFIX_NPM_CLI_JS%"
)

"%NODE_EXE%" "%NPM_CLI_JS%" %*

I didn't dig deeper into the issue, so I don't have any real fix, but a workaround : I removed the loop and it just worked in my case.

:: Created by npm, please don't edit manually.
@ECHO OFF

SETLOCAL

SET "NODE_EXE=%~dp0\node.exe"
IF NOT EXIST "%NODE_EXE%" (
  SET "NODE_EXE=node"
)

SET "NPM_CLI_JS=%~dp0\node_modules\npm\bin\npm-cli.js"

"%NODE_EXE%" "%NPM_CLI_JS%" %*

I faced the same problem when the node-red run in a proxy network. while starting node-red NodeJs check for update information and this TCP communication is getting blocked.
As a workaround we can comment 'updateNotifier.checkNpm()' method calling part in the "C:\Program Files\nodejs\node_modules\npm\node_modules\update-notifier\check.js" file

Here's what's going on behind the scenes: https://npm.community/t/npm-version-takes-3-minutes-to-complete-when-run-in-child-process-and-behind-corporate-proxy/1658

I've see this annoying 3m start up delay of node-red on windows 7, 10, 2012, 2016. Gonna try what @KarnanKurup suggested tomorrow.

Finally - node-red startup 3 minutes faster!

For anyone behind a proxy having a 3 minute delay starting node-red...

  • Using notepad/text editor, open node-red.cmd (look in you NPM Global folder)
  • Add the following line to the top of the file (before any other command)
    SET NO_UPDATE_NOTIFIER=1
  • Start node-red using the cmd file
    node-red.cmd
  • Enjoy the extra 3 mins :slight_smile:

Thanks to @hotNipi, @KarnanKurup for pointing me in the right direction .

6 Likes

works even for v0.20.7

Can I enjoy 3 more minutes if I start Node-RED in the following way?

node --max-old-space-size=8192 C:\Users\admin\AppData\Roaming\npm\node_modules\node-red\red.js

Yes - if you SET NO_UPDATE_NOTIFIER=1 environment variable in the terminal before running node .....

alternatively add NO_UPDATE_NOTIFIER=1 to global environment variables

alternatively, make your own batch file node-red-spacesize8192.cmd with the text...

SET NO_UPDATE_NOTIFIER=1
node --max-old-space-size=8192 C:\Users\admin\AppData\Roaming\npm\node_modules\node-red\red.js
2 Likes

Thank you for your kind guidance!