This is the first time I am using Node-RED on Raspberry PI OS that has been installed into a PC. I didn't know this was even possible until recently, but the install was a success and now I'm trying to get my node-RED application working.
A fresh node-RED installation, however, has produced new issues I have not seen on Raspberry Pi before.
I used the bash script to install Node-RED on a brand-new install of Raspberry Pi OS on a PC. That seemed to work without errors.
However, when I start node red locally, Node-RED cannot be reached in the browser and I get the following in node-red-log:
# Fatal javascript OOM in GC during deserialization
#
nodered.service: Main process exited, code=killed, status=5/TRAP
nodered.service: Failed with result 'signal'.
nodered.service: Scheduled restart job, restart counter is at 9.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
<--- Last few GCs --->
<--- JS stacktrace --->
What I have tried that has not worked:
Running the bash script again to uninstall/reinstall
Remove the raspberry-pi specific nodes (since I'm not physically on a raspberry pi)
What I have tried that does apparently work:
node-red-pi --max-old-space-size=256
My questions:
Is there a way to run with this setting by default? For my application, I have to auto-start node-red as a service on reboot. When I enable node-red as an autostart service, it starts in such a way that I get the above errors.
Does anyone have any idea what the underlying issue could be, since the fatal error on startup does not usually happen on my other node-red applications?
What hardware are you actually running on ?
Which version of nodejs ended up being installed ? node -v
What does the command uname -m report ?
What does the command getconf LONG_BIT report ?
What does the command cat /proc/meminfo | grep MemTotal report ?
I have been playing around with uninstalling/reinstalling. The Node.js version is 14 as of this moment but the error and behavior is the same.
27 Jul 14:30:14 - [info]
Welcome to Node-RED
===================
27 Jul 14:30:14 - [info] Node-RED version: v3.0.1
27 Jul 14:30:14 - [info] Node.js version: v14.20.0
27 Jul 14:30:14 - [info] Linux 5.10.0-15-amd64 ia32 LE
27 Jul 14:30:14 - [info] Loading palette nodes
27 Jul 14:30:15 - [info] Settings file : /home/pi/.node-red/settings.js
27 Jul 14:30:15 - [info] Context store : 'default' [module=memory]
27 Jul 14:30:15 - [info] User directory : /home/pi/.node-red
27 Jul 14:30:15 - [warn] Projects disabled : editorTheme.projects.enabled=false
27 Jul 14:30:15 - [info] Flows file : /home/pi/.node-red/flows.json
27 Jul 14:30:15 - [info] Creating new flow file
27 Jul 14:30:15 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
27 Jul 14:30:15 - [warn] Encrypted credentials not found
27 Jul 14:30:15 - [info] Server now running at http://127.0.0.1:1880/
27 Jul 14:30:15 - [info] Starting flows
27 Jul 14:30:15 - [info] Started flows
Start Node-RED
Once Node-RED has started, point a browser at http://192.168.10.114:1880
On Pi Node-RED works better with the Firefox or Chrome browser
Use node-red-stop to stop Node-RED
Use node-red-start to start Node-RED again
Use node-red-log to view the recent log output
Use sudo systemctl enable nodered.service to autostart Node-RED at every boot
Use sudo systemctl disable nodered.service to disable autostart on boot
To find more nodes and example flows - go to http://flows.nodered.org
Starting as a systemd service.
<--- Last few GCs --->
[2705:0xd5e5290] 85 ms: Mark-sweep 1.3 (3.8) -> 1.3 (3.8) MB, 1.3 / 0.0 ms (average mu = 0.684, current mu = 0.187) allocation failure GC in old space requested
[2705:0xd5e5290] 87 ms: Mark-sweep (reduce) 1.3 (3.8) -> 1.3 (3.8) MB, 1.3 / 0.0 ms (average mu = 0.567, current mu = 0.235) last resort GC in old space requested
[2705:0xd5e5290] 89 ms: Mark-sweep (reduce) 1.3 (2.8) -> 1.3 (3.8) MB, 1.7 / 0.0 ms (average mu = 0.376, current mu = 0.005) last resort GC in old space requested
<--- JS stacktrace --->
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: 0x8608ce1 node::Abort() [node]
2: 0x86091ec node::OnFatalError(char const*, char const*) [node]
3: 0x8796e28 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
4: 0x87971cd v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
5: 0x8964f19 [node]
6: 0x897660e v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
7: 0x894a0e3 v8::internal::HeapObject v8::internal::Heap::AllocateRawWith<(v8::internal::Heap::AllocationRetryMode)1>(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
8: 0x894b732 v8::internal::Factory::CodeBuilder::BuildInternal(bool) [node]
9: 0x894bae8 v8::internal::Factory::CodeBuilder::Build() [node]
10: 0x8f45b7e v8::internal::RegExpMacroAssemblerIA32::GetCode(v8::internal::Handle<v8::internal::String>) [node]
11: 0x8c45134 v8::internal::RegExpCompiler::Assemble(v8::internal::Isolate*, v8::internal::RegExpMacroAssembler*, v8::internal::RegExpNode*, int, v8::internal::Handle<v8::internal::String>) [node]
12: 0x8c65419 v8::internal::RegExpImpl::Compile(v8::internal::Isolate*, v8::internal::Zone*, v8::internal::RegExpCompileData*, v8::base::Flags<v8::internal::JSRegExp::Flag, int>, v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::String>, bool, unsigned int) [node]
13: 0x8c65c99 v8::internal::RegExpImpl::CompileIrregexp(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, bool) [node]
14: 0x8c667d7 v8::internal::RegExp::IrregexpPrepare(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>) [node]
15: 0x8c66868 v8::internal::RegExpImpl::IrregexpExec(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, int, v8::internal::Handle<v8::internal::RegExpMatchInfo>) [node]
16: 0x8c6837b v8::internal::RegExp::Exec(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, int, v8::internal::Handle<v8::internal::RegExpMatchInfo>) [node]
17: 0x8cbfee8 v8::internal::Runtime_RegExpExec(int, unsigned int*, v8::internal::Isolate*) [node]
18: 0x901fb77 [node]
19: 0x90682c2 [node]
20: 0x8fc3219 [node]
21: 0x8fbdd72 [node]
22: 0x8fc3219 [node]
23: 0x8fbdd72 [node]
24: 0x8fc3219 [node]
25: 0x8fc3219 [node]
26: 0x8fc3219 [node]
27: 0x8fc3219 [node]
28: 0x8fc3219 [node]
29: 0x8fc3219 [node]
30: 0x8fc3219 [node]
31: 0x8fc3219 [node]
32: 0x8fc3219 [node]
33: 0x8fc3219 [node]
34: 0x8fc139a [node]
35: 0x8fc11bb [node]
36: 0x88f2dab [node]
37: 0x88f3536 v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*) [node]
38: 0x87a85f2 v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) [node]
39: 0x85c8a29 node::ExecuteBootstrapper(node::Environment*, char const*, std::vector<v8::Local<v8::String>, std::allocator<v8::Local<v8::String> > >*, std::vector<v8::Local<v8::Value>, std::allocator<v8::Local<v8::Value> > >*) [node]
40: 0x85c8d18 [node]
41: 0x85ca0c2 node::StartExecution(node::Environment*, std::function<v8::MaybeLocal<v8::Value> (node::StartExecutionCallbackInfo const&)>) [node]
42: 0x855e05d node::LoadEnvironment(node::Environment*) [node]
43: 0x864be4e node::NodeMainInstance::Run() [node]
44: 0x85cc51e node::Start(int, char**) [node]
45: 0x85576ba main [node]
46: 0xf79f9e46 __libc_start_main [/lib/i386-linux-gnu/libc.so.6]
nodered.service: Main process exited, code=killed, status=6/ABRT
nodered.service: Failed with result 'signal'.
/
/
/
/
/
/ /lib/systemd/system/nodered.service:
# systemd service file to start Node-RED
[Unit]
Description=Node-RED graphical event wiring tool
Wants=network.target
Documentation=http://nodered.org/docs/hardware/raspberrypi.html
[Service]
Type=simple
# Run as normal pi user - change to the user name you wish to run Node-RED as
User=pi
Group=pi
WorkingDirectory=/home/pi
Environment="NODE_OPTIONS=--max_old_space_size=4096"
# define an optional environment file in Node-RED's user directory to set custom variables externally
EnvironmentFile=-/home/pi/.node-red/environment
# uncomment and edit next line if you need an http proxy
#Environment="HTTP_PROXY=my.httpproxy.server.address"
# uncomment the next line for a more verbose log output
#Environment="NODE_RED_OPTIONS=-v"
# uncomment next line if you need to wait for time sync before starting
#ExecStartPre=/bin/bash -c '/bin/journalctl -b -u systemd-timesyncd | /bin/grep -q "systemd-timesyncd.* Synchronized to time server"'
ExecStart=/usr/bin/env node-red-pi $NODE_OPTIONS $NODE_RED_OPTIONS
#ExecStart=/usr/bin/env node $NODE_OPTIONS red.js $NODE_RED_OPTIONS
# Use SIGINT to stop
KillSignal=SIGINT
# Auto restart on crash
Restart=on-failure
RestartSec=20
# Tag things in the log
SyslogIdentifier=Node-RED
#StandardOutput=syslog
[Install]
WantedBy=multi-user.target
Something very odd is going on, obviously.
What about node-red-pi --max_old_space_size=4096
and /usr/bin/env node-red-pi --max_old_space_size=4096
I am trying to find a command line that fails, other than running it from the service file, which does fail.
Also does this give any output? echo $NODE_RED_OPTIONS
Does the file /home/pi/.node-red/environment exist? If so then what is in it?
I think we are getting somewhere. So node-red-pi --max_old_space_size=4096 fails with out of memory, but node-red-pi --max_old_space_size=256 is ok. I think that may mean that in fact the process does not have as much memory as it should. But I think I need to hand over to @knolleary at this point.
To get you going I suggest you edit the service file and comment out the Environment line where it sets NODE_OPTIONS, so that the ExecStart line runs node-red-pi without any options. Run sudo systemctl daemon-reload, or reboot, after editing the service file, in order to tell the system to re-read it.
Thanks for the help. The space allocation definitely seems to be at the root of it all. So far, node-red has been running fine as a service after removing --max_old_space_size=4096 from the service file.
Since it's a new PC + OS install I'm wondering if the swap and memory isn't configured in the best possible way. OS installation on new hardware is definitely out of my wheel house. I just pushed through it with default/recommended settings until everything seemed to work.