                 if err
                     opts.cb(err)
                 else
+                    if client.live.length > @max_length
+                        client.live = client.live.slice(0,@max_length)
                     @clients[opts.session_id] = client
                     opts.cb(undefined, client)
 
     sync: (cb) =>
         @_call_with_lock(@_sync, cb)
 
-    _sync: (cb) =>
+    _sync: (cb, retry) =>
         last = @head
         #winston.debug("sync: last='#{last}'")
         all = {}

        @push_edits_to_browser(undefined, cb)

# A string that is synchronized amongst all connected clients.
class SynchronizedString
    constructor: (@string_id) ->
        misc.call_lock(obj:@)
        @clients = {}
        @head = ''

    new_browser_client: (opts) =>
        opts = defaults opts,

    ], (err) =>
        if err
            # TODO: undo any other harm
            opts.cb(err)
        else
            sync_strings[opts.string_id] = S
            opts.cb(undefined, S)
    )

exports.syncstring = (opts) ->
