diff --git a/packages/ddp-client/common/MethodInvoker.js b/packages/ddp-client/common/MethodInvoker.js index 0312ea900e..f2490b92f8 100644 --- a/packages/ddp-client/common/MethodInvoker.js +++ b/packages/ddp-client/common/MethodInvoker.js @@ -46,7 +46,6 @@ export default class MethodInvoker { // Invoke the callback, if we have both a result and know that all data has // been written to the local cache. _maybeInvokeCallback() { - console.log(this._methodResult, this._dataVisible); if (this._methodResult && this._dataVisible) { // Call the callback. (This won't throw: the callback was wrapped with // bindEnvironment.) diff --git a/packages/ddp-server/livedata_server.js b/packages/ddp-server/livedata_server.js index b1fd001612..4c12fa04c4 100644 --- a/packages/ddp-server/livedata_server.js +++ b/packages/ddp-server/livedata_server.js @@ -1545,9 +1545,7 @@ Server = function (options = {}) { socket.on('close', function () { if (socket._meteorSession) { - Meteor._runAsync(function() { - socket._meteorSession.close(); - }); + socket._meteorSession.close(); } }); }); diff --git a/packages/minimongo/cursor.js b/packages/minimongo/cursor.js index 6735e132d5..a344b99661 100644 --- a/packages/minimongo/cursor.js +++ b/packages/minimongo/cursor.js @@ -227,7 +227,7 @@ export default class Cursor { * @param {Object} callbacks Functions to call to deliver the result set as it * changes */ - observeChanges(options) { + async observeChanges(options) { const ordered = LocalCollection._observeChangesCallbacksAreOrdered(options); // there are several places that assume you aren't combining skip/limit with @@ -369,7 +369,7 @@ export default class Cursor { // run the observe callbacks resulting from the initial contents // before we leave the observe. - this.collection._observeQueue.drain(); + await this.collection._observeQueue.drain(); return handle; } diff --git a/packages/mongo/observe_changes_tests.js b/packages/mongo/observe_changes_tests.js index 43e318a36f..0479d6a60d 100644 --- a/packages/mongo/observe_changes_tests.js +++ b/packages/mongo/observe_changes_tests.js @@ -58,34 +58,46 @@ _.each ([{added: 'added', forceOrdered: true}, }); }); -Tinytest.addAsync("observeChanges - callback isolation", function (test, onComplete) { +Tinytest.addAsync('observeChanges - callback isolation', async function( + test, + onComplete +) { var c = makeCollection(); - withCallbackLogger(test, ["added", "changed", "removed"], Meteor.isServer, function (logger) { - var handles = []; - var cursor = c.find(); - handles.push(cursor.observeChanges(logger)); - // fields-tampering observer - handles.push(cursor.observeChanges({ - added: function(id, fields) { - fields.apples = 'green'; - }, - changed: function(id, fields) { - fields.apples = 'green'; - }, - })); + await withCallbackLogger( + test, + ['added', 'changed', 'removed'], + Meteor.isServer, + async function(logger) { + var handles = []; + var cursor = c.find(); + handles.push(await cursor.observeChanges(logger)); + // fields-tampering observer + handles.push( + await cursor.observeChanges({ + added: function(id, fields) { + fields.apples = 'green'; + }, + changed: function(id, fields) { + fields.apples = 'green'; + }, + }) + ); - var fooid = c.insert({apples: "ok"}); - logger.expectResult("added", [fooid, {apples: "ok"}]); + var fooid = await c.insertAsync({ apples: 'ok' }); + logger.expectResult('added', [fooid, { apples: 'ok' }]); - c.update(fooid, {apples: "not ok"}); - logger.expectResult("changed", [fooid, {apples: "not ok"}]); + await c.updateAsync(fooid, { apples: 'not ok' }); - test.equal(c.findOne(fooid).apples, "not ok"); + logger.expectResult('changed', [fooid, { apples: 'not ok' }]); - _.each(handles, function(handle) { handle.stop(); }); - onComplete(); - }); + test.equal((await c.findOneAsync(fooid)).apples, 'not ok'); + for (const handle of handles) { + await handle.stop(); + } + onComplete(); + } + ); }); Tinytest.addAsync("observeChanges - single id - initial adds", function (test, onComplete) {