This week's sprint is going to be dedicated to resolving this condition, which still persists. However, I am certain that I don't know where to start in the diagnosis. I have read a few posts to which some of you have contributed related to JavaScript heap out of memory and they are pretty CSI-like in their forensics.
I have validated that I can cause a JavaScript heap out of memory condition when I hit Deploy. See example log data below, which was created when I tried to deploy a change using Safari. I usually use Firefox, so I don't think that this is browser-dependent.
I have removed all browser extensions from Firefox.
There is also some kind of time element. After an initial failure, or two, I can usually deploy changes without incident as long as I don't wait too long between deployments. If I wait for something that feels likt 15 or 20 minutes, the heap error will occur.
For the first time, I have received this message this morning:
6/17/2019, 7:06:22 AMmsg : string[27]
"Existing flow file is empty"
6/17/2019, 7:06:23 AM
msg : string[122]
"Restoring flow file backup : /home/homemanadmin/.node-red/projects/nodered-homeassistant/.flows_homeMan-server.json.backup"
From time-to-time, this condition will occur when I access my node-red instance from my browser (i.e. http://192.168.14.178:1880) for the first time at the beginning of the day. Such was the case this morning. The Browser Console shows the following:
OpenGL compositor Initialized Succesfully.
Version: 2.1 INTEL-10.36.25
Vendor: Intel Inc.
Renderer: Intel(R) Iris(TM) Graphics 6100
FBO Texture Target: TEXTURE_2D
Unkown category for SetEventRecordingEnabled.
[Exception... "Favicon at "https://sjc1.discourse-cdn.com/favicon.ico" failed to load: Not Found." nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: resource:///modules/FaviconLoader.jsm :: onStopRequest :: line 199" data: no]
window.controllers/Controllers is deprecated. Do not use it for UA detection. ace.js:1:18479
Content Security Policy: Ignoring āx-frame-optionsā because of āframe-ancestorsā directive.
The connection to ws://192.168.14.178:1880/comms was interrupted while the page was loading. red.min.js:16:9313
window.controllers/Controllers is deprecated. Do not use it for UA detection. ace.js:1:18479
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end userās experience. For more help http://xhr.spec.whatwg.org/ vendor.js:5:25379
OpenGL compositor Initialized Succesfully.
Version: 2.1 INTEL-10.36.25
Vendor: Intel Inc.
Renderer: Intel(R) Iris(TM) Graphics 6100
FBO Texture Target: TEXTURE_2D
XHRGEThttps://aus5.mozilla.org/update/3/GMP/67.0.2/20190607204818/Darwin_x86_64-gcc3/en-US/release/Darwin%2017.7.0/default/default/update.xml
[HTTP/2.0 200 OK 1722ms]
As mentioned earlier, this will happen randomly when I am not working in node-red.
Typical top output during steady state on my Ubuntu server. If memory usage is spiking, i am not sure where i can find that historical evidence.
top - 05:46:42 up 2 days, 22:13, 1 user, load average: 0.00, 0.00, 0.01
Tasks: 132 total, 1 running, 131 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.5 us, 0.2 sy, 0.0 ni, 99.2 id, 0.0 wa, 0.0 hi, 0.2 si, 0.0 st
KiB Mem : 3963868 total, 1200036 free, 340512 used, 2423320 buff/cache
KiB Swap: 4108284 total, 4108284 free, 0 used. 3267164 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
20927 homeman+ 20 0 934156 174224 29680 S 0.0 4.4 0:14.10 node-red
2013 homeass+ 20 0 1475236 138844 22236 S 1.0 3.5 11:38.08 hass
1200 root 20 0 174624 19692 11604 S 0.0 0.5 0:00.10 unattended-upgr
948 root 20 0 286936 8092 7144 S 0.0 0.2 0:03.58 accounts-daemon
1320 root 20 0 288180 7740 6916 S 0.0 0.2 0:00.03 polkitd
20762 root 20 0 92832 6836 5904 S 0.0 0.2 0:00.02 sshd
1 root 20 0 120144 6232 4056 S 0.0 0.2 0:03.34 systemd
1329 root 20 0 65512 6092 5384 S 0.0 0.2 0:00.00 sshd
20849 homeman+ 20 0 22860 5644 3484 S 0.0 0.1 0:00.17 bash
20848 homeman+ 20 0 94244 5348 3116 S 0.0 0.1 0:00.28 sshd
471 root 20 0 45820 5304 3180 S 0.0 0.1 0:00.79 systemd-udevd
382 root 20 0 40640 5132 2672 S 0.0 0.1 0:04.78 systemd-journal
1286 mosquit+ 20 0 42224 4884 4300 S 0.0 0.1 0:40.51 mosquitto
20764 homeman+ 20 0 45288 4628 3920 S 0.0 0.1 0:00.01 systemd
909 message+ 20 0 43032 4088 3520 S 0.0 0.1 0:00.27 dbus-daemon
21000 homeman+ 20 0 41812 3860 3252 R 0.0 0.1 0:00.07 top
1236 root 10 -10 5720 3528 2444 S 0.0 0.1 0:11.27 iscsid
959 syslog 20 0 256392 3440 2824 S 0.0 0.1 0:02.59 rsyslogd
907 root 20 0 28620 3192 2864 S 0.0 0.1 0:00.22 systemd-logind
953 root 20 0 29008 3048 2776 S 0.0 0.1 0:00.24 cron
1047 root 20 0 16124 2884 2028 S 0.0 0.1 0:00.00 dhclient
810 systemd+ 20 0 100324 2552 2340 S 0.0 0.1 0:00.16 systemd-timesyn
931 root 20 0 309668 2452 1452 S 0.0 0.1 0:02.02 lxcfs
1206 root 20 0 24048 2288 1932 S 0.0 0.1 0:00.00 vsftpd
20765 homeman+ 20 0 143596 2288 0 S 0.0 0.1 0:00.00 (sd-pam)
940 daemon 20 0 26044 2168 1976 S 0.0 0.1 0:00.00 atd
1310 root 20 0 15936 1828 1692 S 0.0 0.0 0:00.00 agetty
438 root 20 0 102968 1804 1576 S 0.0 0.0 0:00.00 lvmetad
944 root 20 0 4396 1220 1132 S 0.0 0.0 0:00.00 acpid
1314 root 20 0 19472 252 0 S 0.0 0.0 0:06.91 irqbalance
992 root 20 0 13372 164 20 S 0.0 0.0 0:00.01 mdadm
1235 root 20 0 5220 148 36 S 0.0 0.0 0:02.10 iscsid
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
Example log entries.
<--- Last few GCs --->
[20878:0x30b2060] 261842 ms: Mark-sweep 120.3 (133.8) -> 119.6 (133.8) MB, 179.5 / 0.0 ms (average mu = 0.155, current mu = 0.051) allocation failure scavenge might not succeed
[20878:0x30b2060] 262035 ms: Mark-sweep 120.5 (133.8) -> 119.8 (133.3) MB, 180.0 / 0.0 ms (average mu = 0.114, current mu = 0.070) allocation failure scavenge might not succeed
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x360c1434fb5d]
Security context: 0x12df3009d9f1 <JSObject>
1: _clone(aka _clone) [0x357d3e728509] [/usr/lib/node_modules/node-red/node_modules/clone/clone.js:~73] [pc=0x360c14ae14c2](this=0x2d0671f025b1 <undefined>,0x21b317a14ca1 <Object map = 0x2298466fbf11>,0x10f6ed4e3051 <HeapNumber inf>)
2: clone(aka clone) [0x243e5265761] [/usr/lib/node_modules/node-red/node_modules/clone/clone.js:~52] [pc=0x360c14adeda...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x944930 node::Abort() [node-red]
2: 0x9457dc node::OnFatalError(char const*, char const*) [node-red]
3: 0xb0d01e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node-red]
4: 0xb0d254 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node-red]
5: 0xf09822 [node-red]
6: 0xf09928 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [node-red]
7: 0xf16048 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node-red]
8: 0xf16b5b v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node-red]
9: 0xf19891 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [node-red]
10: 0xee3ac4 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [node-red]
11: 0x11994ae v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [node-red]
12: 0x360c1434fb5d
2019-06-17 05:32:24 ERROR (MainThread) [aiohttp.server] Unhandled exception
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 448, in start
await resp.write_eof()
File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_response.py", line 444, in write_eof
await self._payload_writer.write_eof(data)
File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/http_writer.py", line 138, in write_eof
self._write(chunk)
File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/http_writer.py", line 67, in _write
raise ConnectionResetError('Cannot write to closing transport')
ConnectionResetError: Cannot write to closing transport
2019-06-17 05:32:24 ERROR (MainThread) [aiohttp.server] Unhandled exception
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 448, in start
await resp.write_eof()
File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_response.py", line 444, in write_eof
await self._payload_writer.write_eof(data)
File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/http_writer.py", line 138, in write_eof
self._write(chunk)
File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/http_writer.py", line 67, in _write
raise ConnectionResetError('Cannot write to closing transport')
ConnectionResetError: Cannot write to closing transport
2019-06-17 05:32:24 ERROR (MainThread) [aiohttp.server] Unhandled exception
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 448, in start
await resp.write_eof()
File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_response.py", line 444, in write_eof
await self._payload_writer.write_eof(data)
File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/http_writer.py", line 138, in write_eof
self._write(chunk)
node-red.service: Main process exited, code=dumped, status=6/ABRT
File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/http_writer.py", line 67, in _write
raise ConnectionResetError('Cannot write to closing transport')
ConnectionResetError: Cannot write to closing transport
node-red.service: Unit entered failed state.
node-red.service: Failed with result 'core-dump'.
node-red.service: Service hold-off time over, scheduling restart.
Stopped Node-RED.
Started Node-RED.
[UFW BLOCK] IN=enp0s25 OUT= MAC=01:00:5e:00:00:01:c0:56:27:cb:c7:ee:08:00 SRC=192.168.14.97 DST=224.0.0.1 LEN=28 TOS=0x00 PREC=0xC0 TTL=1 ID=58886 PROTO=2
17 Jun 05:32:24 - [info]
Welcome to Node-RED
===================
When a click on Deploy is successful, this is in the Browser Console
XHRGEThttp://192.168.14.178:1880/context/flow/bfe5449b.615498
[HTTP/1.1 200 OK 497ms]
Empty string passed to getElementById().
vendor.js:2:24489
XHRPOSThttp://192.168.14.178:1880/flows
[HTTP/1.1 200 OK 3495ms]
Empty string passed to getElementById().
vendor.js:2:24489
XHRGEThttp://192.168.14.178:1880/projects/nodered-homeassistant/status
[HTTP/1.1 304 Not Modified 254ms]