Permalink
Browse files

Don't throw an exception if the document is not loaded when removing …

…listeners.
  • Loading branch information...
1 parent 9f9906a commit 0ada19e318d5761c615a448d66873c612641a19f @nullobject nullobject committed Apr 18, 2012
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/server/model.coffee
View
@@ -565,12 +565,15 @@ module.exports = Model = (db, options) ->
#
# This is synchronous.
@removeListener = (docName, listener) ->
- # The document should already be loaded.
doc = docs[docName]
- throw new Error 'removeListener called but document not loaded' unless doc
- doc.eventEmitter.removeListener 'op', listener
- refreshReapingTimeout docName
+ console.log "Model#removeListener: document '#{docName}' disconnecting..."
+
+ if not doc?
+ console.warn "Model#removeListener: document '#{docName}' not loaded"
+ else
+ doc.eventEmitter.removeListener 'op', listener
+ refreshReapingTimeout docName
# Flush saves all snapshot data to the database. I'm not sure whether or not this is actually needed -
# sharejs will happily replay uncommitted ops when documents are re-opened anyway.

0 comments on commit 0ada19e

Please sign in to comment.