Custom App - Save JS file and bench stops

I created a custom app, and when I edit any js file in my app, bench stops with the follow… I cant seem to edit without having to tab to a terminal and run bench start. Is this normal?

Error message that shows is:

20:04:23 watch.1          | Wrote js/erpnext-web.min.js - 4.22 KB
20:04:23 watch.1          | Wrote js/erpnext.min.js - 171.74 KB
20:04:23 watch.1          | Wrote js/item-dashboard.min.js - 8.41 KB
20:04:23 watch.1          | Wrote custom_styles/css/custom_styles.css - 1.21 KB
20:04:23 watch.1          | Wrote custom_styles/js/custom_styles.js - 694 B
20:04:33 watch.1          | /home/frappe/frappe-bench/apps/frappe/frappe/build.js:295
20:04:33 watch.1          | 			if (sources.includes(filename)) {
20:04:33 watch.1          | 			            ^
20:04:33 watch.1          |
20:04:33 watch.1          | TypeError: sources.includes is not a function
20:04:33 watch.1          |     at FSWatcher.<anonymous> (/home/frappe/frappe-bench/apps/frappe/frappe/build.js:295:16)
20:04:33 watch.1          |     at emitTwo (events.js:100:13)
20:04:33 watch.1          |     at FSWatcher.emit (events.js:185:7)
20:04:33 watch.1          |     at FSWatcher.<anonymous> (/home/frappe/frappe-bench/node_modules/chokidar/index.js:196:15)
20:04:33 watch.1          |     at FSWatcher._emit (/home/frappe/frappe-bench/node_modules/chokidar/index.js:238:5)
20:04:33 watch.1          |     at FSWatcher.<anonymous> (/home/frappe/frappe-bench/node_modules/chokidar/lib/nodefs-handler.js:263:16)
20:04:33 watch.1          |     at FSReqWrap.oncomplete (fs.js:82:15)
20:04:33 system           | watch.1 stopped (rc=0)
20:04:33 system           | sending SIGTERM to redis_socketio.1 (pid 2168)
20:04:33 system           | sending SIGTERM to worker_long.1 (pid 2166)
20:04:33 system           | sending SIGTERM to redis_queue.1 (pid 2167)
20:04:33 system           | sending SIGTERM to web.1 (pid 2189)
20:04:33 system           | sending SIGTERM to schedule.1 (pid 2178)
20:04:33 system           | sending SIGTERM to worker_default.1 (pid 2175)
20:04:33 system           | sending SIGTERM to socketio.1 (pid 2169)
20:04:33 system           | sending SIGTERM to redis_cache.1 (pid 2173)
20:04:33 system           | sending SIGTERM to worker_short.1 (pid 2192)
20:04:33 redis_socketio.1 | [2177 | signal handler] (1519963473) Received SIGTERM, scheduling shutdown...
20:04:33 worker_long.1    | 20:04:33 Warm shut down requested
20:04:33 redis_queue.1    | [2172 | signal handler] (1519963473) Received SIGTERM, scheduling shutdown...
20:04:33 system           | schedule.1 stopped (rc=-15)
20:04:33 worker_default.1 | 20:04:33 Warm shut down requested
20:04:33 redis_socketio.1 | [2177] 01 Mar 20:04:33.474 # User requested shutdown...
20:04:33 redis_socketio.1 | [2177] 01 Mar 20:04:33.474 # Redis is now ready to exit, bye bye...
20:04:33 system           | redis_socketio.1 stopped (rc=-15)
20:04:33 redis_queue.1    | [2172] 01 Mar 20:04:33.492 # User requested shutdown...
20:04:33 redis_queue.1    | [2172] 01 Mar 20:04:33.492 # Redis is now ready to exit, bye bye...
20:04:33 system           | redis_queue.1 stopped (rc=-15)
20:04:33 system           | socketio.1 stopped (rc=-15)
20:04:33 worker_short.1   | Traceback (most recent call last):
20:04:33 worker_short.1   |   File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
20:04:33 redis_cache.1    | [2200 | signal handler] (1519963473) Received SIGTERM, scheduling shutdown...
20:04:33 worker_short.1   |     "__main__", fname, loader, pkg_name)
20:04:33 worker_short.1   |   File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
20:04:33 worker_short.1   |     exec code in run_globals
20:04:33 worker_short.1   |   File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 94, in <module>
20:04:33 worker_short.1   |     main()
20:04:33 worker_short.1   |   File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
20:04:33 worker_short.1   |     click.Group(commands=commands)(prog_name='bench')
20:04:33 worker_short.1   |   File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 722, in __call__
20:04:33 worker_short.1   |     return self.main(*args, **kwargs)
20:04:33 worker_short.1   |   File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 697, in main
20:04:33 worker_short.1   |     rv = self.invoke(ctx)
20:04:33 worker_short.1   |   File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
20:04:33 worker_short.1   |     return _process_result(sub_ctx.command.invoke(sub_ctx))
20:04:33 worker_short.1   |   File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
20:04:33 worker_short.1   |     return _process_result(sub_ctx.command.invoke(sub_ctx))
20:04:33 worker_short.1   |   File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 895, in invoke
20:04:33 worker_short.1   |     return ctx.invoke(self.callback, **ctx.params)
20:04:33 worker_short.1   |   File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
20:04:33 worker_short.1   |     return callback(*args, **kwargs)
20:04:33 worker_short.1   |   File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/scheduler.py", line 158, in start_worker
20:04:33 worker_short.1   |     start_worker(queue, quiet = quiet)
20:04:33 worker_short.1   |   File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 142, in start_worker
20:04:33 worker_short.1   |     Worker(queues, name=get_worker_name(queue)).work(logging_level = logging_level)
20:04:33 worker_short.1   |   File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/rq/worker.py", line 483, in work
20:04:33 redis_cache.1    | [2200] 01 Mar 20:04:33.549 # User requested shutdown...
20:04:33 redis_cache.1    | [2200] 01 Mar 20:04:33.549 # Redis is now ready to exit, bye bye...
20:04:33 worker_short.1   |     self.register_death()
20:04:33 worker_short.1   |   File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/rq/worker.py", line 282, in register_death
20:04:33 worker_short.1   |     p.execute()
20:04:33 worker_short.1   |   File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/redis/client.py", line 2894, in execute
20:04:33 worker_short.1   |     return execute(conn, stack, raise_on_error)
20:04:33 worker_short.1   |   File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/redis/client.py", line 2749, in _execute_transaction
20:04:33 worker_short.1   |     connection.send_packed_command(all_cmds)
20:04:33 worker_short.1   |   File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/redis/connection.py", line 585, in send_packed_command
20:04:33 system           | redis_cache.1 stopped (rc=-15)
20:04:33 worker_short.1   |     self.connect()
20:04:33 worker_short.1   |   File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/redis/connection.py", line 489, in connect
20:04:33 worker_short.1   |     raise ConnectionError(self._error_message(e))
20:04:33 worker_short.1   | redis.exceptions.ConnectionError: Error 111 connecting to localhost:11000. Connection refused.
20:04:33 system           | worker_short.1 stopped (rc=-15)
20:04:33 system           | worker_long.1 stopped (rc=-15)
20:04:33 system           | worker_default.1 stopped (rc=-15)
20:04:33 web.1            | Exception in thread Thread-2 (most likely raised during interpreter shutdown):Exception in thread Thread-9 (most likely raised during interpreter shutdown):Exception in thread Thread-1 (most likely raised during interpreter shutdown):
20:04:33 web.1            | Traceback (most recent call last):
20:04:33 web.1            | Traceback (most recent call last):
20:04:33 web.1            |   File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
20:04:33 web.1            |   File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/watchdog/observers/api.py", line 182, in run
20:04:33 web.1            | Traceback (most recent call last):
20:04:33 web.1            |
20:04:33 web.1            |   File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/watchdog/observers/inotify.py", line 131, in queue_events
20:04:33 web.1            |   File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/watchdog/observers/inotify_buffer.py", line 82, in read_event
20:04:33 web.1            | <type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'time'
20:04:33 web.1            |   File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
20:04:33 web.1            |   File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/watchdog/observers/api.py", line 237, in run
20:04:33 web.1            | <type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'Empty'
20:04:33 web.1            |
20:04:33 web.1            |   File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
20:04:33 web.1            |   File "/usr/lib/python2.7/threading.py", line 763, in run
20:04:33 web.1            |   File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 702, in inner
20:04:33 web.1            |   File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 539, in serve_forever
20:04:33 web.1            |   File "/usr/lib/python2.7/SocketServer.py", line 241, in serve_forever
20:04:33 web.1            |   File "/usr/lib/python2.7/threading.py", line 585, in set
20:04:33 web.1            |   File "/usr/lib/python2.7/threading.py", line 406, in notifyAll
20:04:33 web.1            | <type 'exceptions.TypeError'>: 'NoneType' object is not callable
20:04:33 system           | web.1 stopped (rc=-15)

Once I run bench start again, the edits to my file do show up on the site. So my build.js and hook.py seem to be working…

See if this works.

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p 

https://github.com/gulpjs/gulp/issues/217

I tried the command but it still errors out.

05:12:00 web.1            | INFO:werkzeug:192.168.2.4 - - [02/Mar/2018 05:12:00] "POST / HTTP/1.1" 200 -
05:12:08 watch.1          | /home/frappe/frappe-bench/apps/frappe/frappe/build.js:295
05:12:08 watch.1          | 			if (sources.includes(filename)) {
05:12:08 watch.1          | 			            ^
05:12:08 watch.1          |
05:12:08 watch.1          | TypeError: sources.includes is not a function
05:12:08 watch.1          |     at FSWatcher.<anonymous> (/home/frappe/frappe-bench/apps/frappe/frappe/build.js:295:16)
05:12:08 watch.1          |     at emitTwo (events.js:100:13)
05:12:08 watch.1          |     at FSWatcher.emit (events.js:185:7)
05:12:08 watch.1          |     at FSWatcher.<anonymous> (/home/frappe/frappe-bench/node_modules/chokidar/index.js:196:15)
05:12:08 watch.1          |     at FSWatcher._emit (/home/frappe/frappe-bench/node_modules/chokidar/index.js:238:5)
05:12:08 watch.1          |     at FSWatcher.<anonymous> (/home/frappe/frappe-bench/node_modules/chokidar/lib/nodefs-handler.js:263:16)
05:12:08 watch.1          |     at FSReqWrap.oncomplete (fs.js:82:15)
05:12:08 system           | watch.1 stopped (rc=0)
05:12:08 system           | sending SIGTERM to redis_socketio.1 (pid 3082)
05:12:08 system           | sending SIGTERM to worker_long.1 (pid 3080)
05:12:08 system           | sending SIGTERM to redis_queue.1 (pid 3079)
05:12:08 system           | sending SIGTERM to web.1 (pid 3081)
05:12:08 system           | sending SIGTERM to schedule.1 (pid 3084)
05:12:08 system           | sending SIGTERM to worker_default.1 (pid 3104)
05:12:08 system           | sending SIGTERM to socketio.1 (pid 3083)
05:12:08 system           | sending SIGTERM to redis_cache.1 (pid 3090)
05:12:08 system           | sending SIGTERM to worker_short.1 (pid 3108)
05:12:08 redis_socketio.1 | [3089 | signal handler] (1519996328) Received SIGTERM, scheduling shutdown...
05:12:08 worker_long.1    | 05:12:08 Warm shut down requested
05:12:08 redis_socketio.1 | [3089] 02 Mar 05:12:08.326 # User requested shutdown...
05:12:08 redis_socketio.1 | [3089] 02 Mar 05:12:08.326 # Redis is now ready to exit, bye bye...
05:12:08 system           | redis_socketio.1 stopped (rc=-15)
05:12:08 redis_queue.1    | [3085 | signal handler] (1519996328) Received SIGTERM, scheduling shutdown...
05:12:08 system           | schedule.1 stopped (rc=-15)
05:12:08 worker_default.1 | 05:12:08 Warm shut down requested
05:12:08 system           | socketio.1 stopped (rc=-15)
05:12:08 redis_cache.1    | [3111 | signal handler] (1519996328) Received SIGTERM, scheduling shutdown...
05:12:08 worker_short.1   | 05:12:08 Warm shut down requested
05:12:08 redis_cache.1    | [3111] 02 Mar 05:12:08.427 # User requested shutdown...
05:12:08 redis_cache.1    | [3111] 02 Mar 05:12:08.427 # Redis is now ready to exit, bye bye...
05:12:08 redis_queue.1    | [3085] 02 Mar 05:12:08.426 # User requested shutdown...
05:12:08 redis_queue.1    | [3085] 02 Mar 05:12:08.426 # Redis is now ready to exit, bye bye...
05:12:08 system           | redis_queue.1 stopped (rc=-15)
05:12:08 system           | redis_cache.1 stopped (rc=-15)
05:12:08 system           | worker_long.1 stopped (rc=-15)
05:12:08 system           | worker_short.1 stopped (rc=-15)
05:12:08 system           | worker_default.1 stopped (rc=-15)
05:12:08 web.1            | Unhandled exception in thread started by <bound method InotifyEmitter.__bootstrap of <InotifyEmitter(Thread-9, stopped daemon -1326478528)>>Unhandled exception in thread started by <bound method Thread.__bootstrap of <Thread(Thread-1, stopped daemon -1246905536)>>
05:12:08 web.1            | Traceback (most recent call last):
05:12:08 web.1            |   File "/usr/lib/python2.7/threading.py", line 783, in __bootstrap
05:12:08 web.1            |
05:12:08 web.1            | Traceback (most recent call last):
05:12:08 web.1            |   File "/usr/lib/python2.7/threading.py", line 783, in __bootstrap
05:12:08 web.1            |     self.__bootstrap_inner()
05:12:08 web.1            |   File "/usr/lib/python2.7/threading.py", line 823, in __bootstrap_inner
05:12:08 web.1            |     (self.name, _format_exc()))
05:12:08 web.1            |   File "/usr/lib/python2.7/traceback.py", line 241, in format_exc
05:12:08 web.1            |     etype, value, tb = sys.exc_info()
05:12:08 web.1            | AttributeError: 'NoneType' object has no attribute 'exc_info'
05:12:08 web.1            |     self.__bootstrap_inner()
05:12:08 web.1            |   File "/usr/lib/python2.7/threading.py", line 823, in __bootstrap_inner
05:12:08 web.1            |     (self.name, _format_exc()))
05:12:08 web.1            |   File "/usr/lib/python2.7/traceback.py", line 241, in format_exc
05:12:08 web.1            |     etype, value, tb = sys.exc_info()
05:12:08 web.1            | AttributeError: 'NoneType' object has no attribute 'exc_info'
05:12:08 system           | web.1 stopped (rc=-15)

I was using the developer VM… I decided to attempt to build from scratch and the issue has been resolved.