sharedb 5.1.0 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/agent.js CHANGED
@@ -569,7 +569,7 @@ Agent.prototype._querySubscribe = function(queryId, collection, query, options,
569
569
  }
570
570
  this.backend.querySubscribe(this, collection, query, options, function(err, emitter, results, extra) {
571
571
  if (err) return finish(err);
572
- if (this.closed) return emitter.destroy();
572
+ if (agent.closed) return emitter.destroy();
573
573
 
574
574
  agent._subscribeToQuery(emitter, queryId, collection, query);
575
575
  // No results are returned when ids are passed in as an option. Instead,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sharedb",
3
- "version": "5.1.0",
3
+ "version": "5.1.1",
4
4
  "description": "JSON OT database backend",
5
5
  "main": "lib/index.js",
6
6
  "dependencies": {
@@ -729,6 +729,29 @@ function commonTests(options) {
729
729
  connection.get('dogs', 'fido').on('error', done).create({age: 3});
730
730
  });
731
731
 
732
+ it('does not reply if the agent is closed before the query returns', function(done) {
733
+ var backend = this.backend;
734
+ var connection = backend.connect();
735
+ var agent = connection.agent;
736
+
737
+ backend.use('query', function(request, next) {
738
+ backend.use('reply', function() {
739
+ done(new Error('unexpected reply'));
740
+ });
741
+
742
+ expect(agent.closed).to.be.false;
743
+ agent.stream.on('close', function() {
744
+ expect(agent.closed).to.be.true;
745
+ next();
746
+ done();
747
+ });
748
+
749
+ agent.close();
750
+ });
751
+
752
+ connection.createSubscribeQuery('dogs', {});
753
+ });
754
+
732
755
  describe('passing agent.custom to the DB adapter', function() {
733
756
  var connection;
734
757
  var expectedArg = {