Node-red on ubuntu snap everytime restarting because of exception

While starting node-red I'm getting below escption and Oct 24 06:58:19 admin node-

red.node-red[9572]: Welcome to Node-RED
Oct 24 06:58:19 admin node-red.node-red[9572]: ===================
Oct 24 06:58:19 admin node-red.node-red[9572]: 24 Oct 06:58:19 - [info] Node-RED version: v1.0.2
Oct 24 06:58:19 admin node-red.node-red[9572]: 24 Oct 06:58:19 - [info] Node.js  version: v10.16.3
Oct 24 06:58:19 admin node-red.node-red[9572]: 24 Oct 06:58:19 - [info] Linux 4.4.0-164-generic x64 LE
Oct 24 06:58:20 admin node-red.node-red[9572]: 24 Oct 06:58:20 - [info] Loading palette nodes
Oct 24 06:58:24 admin node-red.node-red[9572]: 24 Oct 06:58:24 - [info] Settings file  : /root/snap/node-red/512/settings.js
Oct 24 06:58:24 admin node-red.node-red[9572]: 24 Oct 06:58:24 - [info] Context store  : 'default' [module=memory]
Oct 24 06:58:24 admin node-red.node-red[9572]: 24 Oct 06:58:24 - [info] User directory : /root/snap/node-red/512
Oct 24 06:58:24 admin node-red.node-red[9572]: 24 Oct 06:58:24 - [warn] Projects disabled : editorTheme.projects.enabled=false
Oct 24 06:58:24 admin node-red.node-red[9572]: 24 Oct 06:58:24 - [info] Flows file     : /root/snap/node-red/512/flows.json
Oct 24 06:58:24 admin node-red.node-red[9572]: 24 Oct 06:58:24 - [info] Server now running at http://127.0.0.1:1880/
Oct 24 06:58:24 admin node-red.node-red[9572]: 24 Oct 06:58:24 - [warn]
Oct 24 06:58:24 admin node-red.node-red[9572]: ---------------------------------------------------------------------
Oct 24 06:58:24 admin node-red.node-red[9572]: Your flow credentials file is encrypted using a system-generated key.
Oct 24 06:58:24 admin node-red.node-red[9572]: If the system-generated key is lost for any reason, your credentials
Oct 24 06:58:24 admin node-red.node-red[9572]: file will not be recoverable, you will have to delete it and re-enter
Oct 24 06:58:24 admin node-red.node-red[9572]: your credentials.
Oct 24 06:58:24 admin node-red.node-red[9572]: You should set your own key using the 'credentialSecret' option in
Oct 24 06:58:24 admin node-red.node-red[9572]: your settings file. Node-RED will then re-encrypt your credentials
Oct 24 06:58:24 admin node-red.node-red[9572]: file using your chosen key the next time you deploy a change.
Oct 24 06:58:24 admin node-red.node-red[9572]: ---------------------------------------------------------------------
Oct 24 06:58:24 admin node-red.node-red[9572]: 24 Oct 06:58:24 - [info] Starting flows
Oct 24 06:58:24 admin node-red.node-red[9572]: 24 Oct 06:58:24 - [info] Started flows
Oct 24 06:58:24 admin node-red.node-red[9572]: 24 Oct 06:58:24 - [info] [mqtt-broker:5bb44be3.f0b5bc] Connected to broker: tcp://test.iot.in:1883
Oct 24 06:58:24 admin node-red.node-red[9572]: 0
Oct 24 06:58:24 admin node-red.node-red[9572]: 0
Oct 24 06:58:24 admin node-red.node-red[9572]: 0
Oct 24 06:58:24 admin node-red.node-red[9572]: 0
Oct 24 06:58:24 admin node-red.node-red[9572]: 0
Oct 24 06:58:24 admin node-red.node-red[9572]: 0
Oct 24 06:58:24 admin node-red.node-red[9572]: 0
Oct 24 06:58:24 admin node-red.node-red[9572]: 0
Oct 24 06:59:09 admin node-red.node-red[9572]: 24 Oct 06:59:09 - [error] Uncaught Exception:
Oct 24 06:59:09 admin node-red.node-red[9572]: 24 Oct 06:59:09 - [error] Error: accept EMFILE
Oct 24 06:59:09 admin node-red.node-red[9572]:     at TCP.onconnection (net.js:1496:24)
Oct 24 06:59:10 admin systemd[1]: snap.node-red.node-red.service: Main process exited, code=exited, status=1/FAILURE
Oct 24 06:59:11 admin systemd[1]: snap.node-red.node-red.service: Unit entered failed state.
Oct 24 06:59:11 admin systemd[1]: snap.node-red.node-red.service: Failed with result 'exit-code'.
Oct 24 06:59:11 admin systemd[1]: snap.node-red.node-red.service: Service hold-off time over, scheduling restart.
Oct 24 06:59:11 admin systemd[1]: Stopped Service for snap application node-red.node-red.
Oct 24 06:59:11 admin systemd[1]: Started Service for snap application node-red.node-red.
Oct 24 06:59:11 admin node-red.node-red[9667]: NOW STARTING NODE-RED : /snap/node-red/512/bin/node-red -u /root/snap/node-red/512 on port 1880
Oct 24 06:59:13 admin node-red.node-red[9667]: 24 Oct 06:59:13 - [info]
Oct 24 06:59:13 admin node-red.node-red[9667]: Welcome to Node-RED
Oct 24 06:59:13 admin node-red.node-red[9667]: ===================
Oct 24 06:59:13 admin node-red.node-red[9667]: 24 Oct 06:59:13 - [info] Node-RED version: v1.0.2
Oct 24 06:59:13 admin node-red.node-red[9667]: 24 Oct 06:59:13 - [info] Node.js  version: v10.16.3
Oct 24 06:59:13 admin node-red.node-red[9667]: 24 Oct 06:59:13 - [info] Linux 4.4.0-164-generic x64 LE
Oct 24 06:59:14 admin node-red.node-red[9667]: 24 Oct 06:59:14 - [info] Loading palette nodes
Oct 24 06:59:18 admin node-red.node-red[9667]: 24 Oct 06:59:18 - [info] Settings file  : /root/snap/node-red/512/settings.js
Oct 24 06:59:18 admin node-red.node-red[9667]: 24 Oct 06:59:18 - [info] Context store  : 'default' [module=memory]
Oct 24 06:59:18 admin node-red.node-red[9667]: 24 Oct 06:59:18 - [info] User directory : /root/snap/node-red/512
Oct 24 06:59:18 admin node-red.node-red[9667]: 24 Oct 06:59:18 - [warn] Projects disabled : editorTheme.projects.enabled=false
Oct 24 06:59:18 admin node-red.node-red[9667]: 24 Oct 06:59:18 - [info] Flows file     : /root/snap/node-red/512/flows.json
Oct 24 06:59:18 admin node-red.node-red[9667]: 24 Oct 06:59:18 - [info] Server now running at http://127.0.0.1:1880/
Oct 24 06:59:18 admin node-red.node-red[9667]: 24 Oct 06:59:18 - [warn]
Oct 24 06:59:18 admin node-red.node-red[9667]: ---------------------------------------------------------------------
Oct 24 06:59:18 admin node-red.node-red[9667]: Your flow credentials file is encrypted using a system-generated key.
Oct 24 06:59:18 admin node-red.node-red[9667]: If the system-generated key is lost for any reason, your credentials
Oct 24 06:59:18 admin node-red.node-red[9667]: file will not be recoverable, you will have to delete it and re-enter
Oct 24 06:59:18 admin node-red.node-red[9667]: your credentials.
Oct 24 06:59:18 admin node-red.node-red[9667]: You should set your own key using the 'credentialSecret' option in
Oct 24 06:59:18 admin node-red.node-red[9667]: your settings file. Node-RED will then re-encrypt your credentials
Oct 24 06:59:18 admin node-red.node-red[9667]: file using your chosen key the next time you deploy a change.
Oct 24 06:59:18 admin node-red.node-red[9667]: ---------------------------------------------------------------------
Oct 24 06:59:18 admin node-red.node-red[9667]: 24 Oct 06:59:18 - [info] Starting flows
Oct 24 06:59:18 admin node-red.node-red[9667]: 24 Oct 06:59:18 - [info] Started flows
Oct 24 06:59:18 admin node-red.node-red[9667]: 24 Oct 06:59:18 - [info] [mqtt-broker:5bb44be3.f0b5bc] Connected to broker: tcp://test.iot.in:1883
Oct 24 06:59:18 admin node-red.node-red[9667]: 0
Oct 24 06:59:18 admin node-red.node-red[9667]: 0
Oct 24 06:59:18 admin node-red.node-red[9667]: 0
Oct 24 06:59:18 admin node-red.node-red[9667]: 0
Oct 24 06:59:18 admin node-red.node-red[9667]: 0
Oct 24 06:59:18 admin node-red.node-red[9667]: 0
Oct 24 06:59:18 admin node-red.node-red[9667]: 0
Oct 24 06:59:18 admin node-red.node-red[9667]: 0
^C
root@admin:~# journalctl -f -u snap.node-red*
-- Logs begin at Thu 2019-10-24 05:22:53 UTC. --
Oct 24 06:59:18 admin node-red.node-red[9667]: 24 Oct 06:59:18 - [info] Started flows
Oct 24 06:59:18 admin node-red.node-red[9667]: 24 Oct 06:59:18 - [info] [mqtt-broker:5bb44be3.f0b5bc] Connected to broker: tcp://test.iot.in:1883
Oct 24 06:59:18 admin node-red.node-red[9667]: 0
Oct 24 06:59:18 admin node-red.node-red[9667]: 0
Oct 24 06:59:18 admin node-red.node-red[9667]: 0
Oct 24 06:59:18 admin node-red.node-red[9667]: 0
Oct 24 06:59:18 admin node-red.node-red[9667]: 0
Oct 24 06:59:18 admin node-red.node-red[9667]: 0
Oct 24 06:59:18 admin node-red.node-red[9667]: 0
Oct 24 06:59:18 admin node-red.node-red[9667]: 0
Oct 24 06:59:55 admin node-red.node-red[9667]: Error: EMFILE: too many open files, open '/snap/node-red/512/lib/node_modules/@node-red/editor-client/public/red/images/deploy-reload.svg'
Oct 24 07:00:04 admin node-red.node-red[9667]: 24 Oct 07:00:04 - [error] Uncaught Exception:
Oct 24 07:00:04 admin node-red.node-red[9667]: 24 Oct 07:00:04 - [error] Error: accept EMFILE
Oct 24 07:00:04 admin node-red.node-red[9667]:     at TCP.onconnection (net.js:1496:24)
Oct 24 07:00:05 admin systemd[1]: snap.node-red.node-red.service: Main process exited, code=exited, status=1/FAILURE
Oct 24 07:00:05 admin systemd[1]: snap.node-red.node-red.service: Unit entered failed state.
Oct 24 07:00:05 admin systemd[1]: snap.node-red.node-red.service: Failed with result 'exit-code'.
Oct 24 07:00:06 admin systemd[1]: snap.node-red.node-red.service: Service hold-off time over, scheduling restart.
Oct 24 07:00:06 admin systemd[1]: Stopped Service for snap application node-red.node-red.
Oct 24 07:00:06 admin systemd[1]: Started Service for snap application node-red.node-red.
Oct 24 07:00:06 admin node-red.node-red[9760]: NOW STARTING NODE-RED : /snap/node-red/512/bin/node-red -u /root/snap/node-red/512 on port 1880
Oct 24 07:00:08 admin node-red.node-red[9760]: 24 Oct 07:00:08 - [info]
Oct 24 07:00:08 admin node-red.node-red[9760]: Welcome to Node-RED
Oct 24 07:00:08 admin node-red.node-red[9760]: ===================
Oct 24 07:00:08 admin node-red.node-red[9760]: 24 Oct 07:00:08 - [info] Node-RED version: v1.0.2
Oct 24 07:00:08 admin node-red.node-red[9760]: 24 Oct 07:00:08 - [info] Node.js  version: v10.16.3
Oct 24 07:00:08 admin node-red.node-red[9760]: 24 Oct 07:00:08 - [info] Linux 4.4.0-164-generic x64 LE
Oct 24 07:00:09 admin node-red.node-red[9760]: 24 Oct 07:00:09 - [info] Loading palette nodes
Oct 24 07:00:13 admin node-red.node-red[9760]: 24 Oct 07:00:13 - [info] Settings file  : /root/snap/node-red/512/settings.js
Oct 24 07:00:13 admin node-red.node-red[9760]: 24 Oct 07:00:13 - [info] Context store  : 'default' [module=memory]
Oct 24 07:00:13 admin node-red.node-red[9760]: 24 Oct 07:00:13 - [info] User directory : /root/snap/node-red/512
Oct 24 07:00:13 admin node-red.node-red[9760]: 24 Oct 07:00:13 - [warn] Projects disabled : editorTheme.projects.enabled=false
Oct 24 07:00:13 admin node-red.node-red[9760]: 24 Oct 07:00:13 - [info] Flows file     : /root/snap/node-red/512/flows.json
Oct 24 07:00:13 admin node-red.node-red[9760]: 24 Oct 07:00:13 - [info] Server now running at http://127.0.0.1:1880/
Oct 24 07:00:13 admin node-red.node-red[9760]: 24 Oct 07:00:13 - [warn]
Oct 24 07:00:13 admin node-red.node-red[9760]: ---------------------------------------------------------------------
Oct 24 07:00:13 admin node-red.node-red[9760]: Your flow credentials file is encrypted using a system-generated key.
Oct 24 07:00:13 admin node-red.node-red[9760]: If the system-generated key is lost for any reason, your credentials
Oct 24 07:00:13 admin node-red.node-red[9760]: file will not be recoverable, you will have to delete it and re-enter
Oct 24 07:00:13 admin node-red.node-red[9760]: your credentials.
Oct 24 07:00:13 admin node-red.node-red[9760]: You should set your own key using the 'credentialSecret' option in
Oct 24 07:00:13 admin node-red.node-red[9760]: your settings file. Node-RED will then re-encrypt your credentials
Oct 24 07:00:13 admin node-red.node-red[9760]: file using your chosen key the next time you deploy a change.
Oct 24 07:00:13 admin node-red.node-red[9760]: ---------------------------------------------------------------------
Oct 24 07:00:13 admin node-red.node-red[9760]: 24 Oct 07:00:13 - [info] Starting flows
Oct 24 07:00:13 admin node-red.node-red[9760]: 24 Oct 07:00:13 - [info] Started flows
Oct 24 07:00:13 admin node-red.node-red[9760]: 24 Oct 07:00:13 - [info] [mqtt-broker:5bb44be3.f0b5bc] Connected to broker: tcp://test.iot.in:1883
Oct 24 07:00:13 admin node-red.node-red[9760]: 0
Oct 24 07:00:13 admin node-red.node-red[9760]: 0
Oct 24 07:00:13 admin node-red.node-red[9760]: 0
Oct 24 07:00:13 admin node-red.node-red[9760]: 0
Oct 24 07:00:13 admin node-red.node-red[9760]: 0
Oct 24 07:00:13 admin node-red.node-red[9760]: 0
Oct 24 07:00:13 admin node-red.node-red[9760]: 0
Oct 24 07:00:13 admin node-red.node-red[9760]: 0
^C
root@admin:~# journalctl -f -u snap.node-red*
-- Logs begin at Thu 2019-10-24 05:22:53 UTC. --
Oct 24 07:00:13 admin node-red.node-red[9760]: 24 Oct 07:00:13 - [info] Started flows
Oct 24 07:00:13 admin node-red.node-red[9760]: 24 Oct 07:00:13 - [info] [mqtt-broker:5bb44be3.f0b5bc] Connected to broker: tcp://test.iot.in:1883
Oct 24 07:00:13 admin node-red.node-red[9760]: 0
Oct 24 07:00:13 admin node-red.node-red[9760]: 0
Oct 24 07:00:13 admin node-red.node-red[9760]: 0
Oct 24 07:00:13 admin node-red.node-red[9760]: 0
Oct 24 07:00:13 admin node-red.node-red[9760]: 0
Oct 24 07:00:13 admin node-red.node-red[9760]: 0
Oct 24 07:00:13 admin node-red.node-red[9760]: 0
Oct 24 07:00:13 admin node-red.node-red[9760]: 0

Ubuntu snappy os I'm using and it will restart evry time because of the above exception as I have mentioned.

(edited the title to mention Snap so you can get help from people knowledgeable about that topic)

First thing I see: The error it shows says there are too many files open, and that's why it crashes. However, I do not know enough about Snap to say what exactly is happening here.