             winston.debug("watch: skipping read because watching is off.")
             return
         @_stop_watching_file()
-        fs.readFile @path, (err, data) =>
+        async.series([
+            (cb) =>
+                fs.stat @path, (err, stats) =>
+                    if err
+                        cb(err)
+                    else
+                        cb(check_file_size(stats.size))
+            (cb) =>
+                fs.readFile @path, (err, data) =>
+                    if err
+                        cb(err)
+                    else
+                        @live = data.toString().replace(/\r/g,'')  # NOTE: we immediately delete \r's (see above).
+                        @cm_session.sync_filesystem(cb)
+        ], (err) =>
             if err
-                @_start_watching_file()
-            else
-                @live = data.toString().replace(/\r/g,'')  # NOTE: we immediately delete \r's (see above).
-                @cm_session.sync_filesystem (err) =>
-                    @_start_watching_file()
+                winston.debug("watch: file '#{@path}' error -- #{err}")
+            @_start_watching_file()
+        )
 
     _start_watching_file: () =>
         if @_do_watch?

        # knowing about the backup, in which case it makes more sense
        # to just go with the master.

        no_master = undefined
        stats_path = undefined
        no_backup = undefined
        stats_backup = undefined
        file = undefined

        async.series([
            (cb) =>

json = (out) -> misc.trunc(misc.to_json(out),512)

{ensure_containing_directory_exists, abspath} = misc_node

# We make it an error for a client to try to edit a file larger than MAX_FILE_SIZE.
# I decided on this, because attempts to open a much larger file leads
# to disaster.  Opening a 10MB file works but is a just a little slow.
MAX_FILE_SIZE = 10000000   # 10MB
check_file_size = (size) ->
    if size? and size > MAX_FILE_SIZE
        e = "Attempt to open large file of size #{Math.round(size/1000000)}MB; the maximum allowed size is #{Math.round(MAX_FILE_SIZE/1000000)}MB. Use vim, emacs, or pico from a terminal instead."
        winston.debug(e)
        return e


#####################################################################
# Generate the "secret_token" file as
