Skip to content

Commit

Permalink
Merge branch 'clean-synchronous-cursor-code' of https://github.com/ma…
Browse files Browse the repository at this point in the history
…theusccastroo/meteor into devel

# Conflicts:
#	packages/mongo/mongo_driver.js
#	packages/npm-mongo/.npm/package/npm-shrinkwrap.json
#	packages/webapp/.npm/package/npm-shrinkwrap.json
  • Loading branch information
9Morello committed Sep 20, 2024
2 parents 4cd106e + 4fabb29 commit 9c4a339
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 323 deletions.
7 changes: 3 additions & 4 deletions packages/accounts-base/accounts_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1265,15 +1265,14 @@ export class AccountsServer extends AccountsCommon {
// that would give a lot of power to an attacker with a stolen login
// token and the ability to crash the server.
Meteor.startup(async () => {
const users = await this.users.find({
await this.users.find({
"services.resume.haveLoginTokensToDelete": true
}, {
fields: {
"services.resume.loginTokensToDelete": 1
}
})
users.forEach(user => {
this._deleteSavedTokensForUser(
}).forEachAsync(user => {
return this._deleteSavedTokensForUser(
user._id,
user.services.resume.loginTokensToDelete
)
Expand Down
4 changes: 2 additions & 2 deletions packages/minimongo/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function getAsyncMethodName(method) {
return `${method.replace('_', '')}Async`;
}

export const ASYNC_COLLECTION_METHODS = [
export const COLLECTION_METHODS = [
'_createCappedCollection',
'dropCollection',
'dropIndex',
Expand Down Expand Up @@ -90,7 +90,7 @@ export const ASYNC_COLLECTION_METHODS = [
'upsert',
];

export const ASYNC_CURSOR_METHODS = [
export const CURSOR_METHODS = [
/**
* @deprecated in 2.9
* @summary Returns the number of documents that match a query. This method is
Expand Down
4 changes: 2 additions & 2 deletions packages/minimongo/cursor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import LocalCollection from './local_collection.js';
import { hasOwn } from './common.js';
import { ASYNC_CURSOR_METHODS, getAsyncMethodName } from './constants';
import { CURSOR_METHODS, getAsyncMethodName } from './constants';

// Cursor: a specification for a particular subset of documents, w/ a defined
// order, limit, and offset. creating a Cursor with LocalCollection.find(),
Expand Down Expand Up @@ -558,7 +558,7 @@ export default class Cursor {
}

// Implements async version of cursor methods to keep collections isomorphic
ASYNC_CURSOR_METHODS.forEach(method => {
CURSOR_METHODS.forEach(method => {
const asyncName = getAsyncMethodName(method);
Cursor.prototype[asyncName] = function(...args) {
try {
Expand Down
5 changes: 0 additions & 5 deletions packages/mongo/collection.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
// options.connection, if given, is a LivedataClient or LivedataServer
// XXX presently there is no way to destroy/clean up a Collection
import {
ASYNC_COLLECTION_METHODS,
getAsyncMethodName,
} from 'meteor/minimongo/constants';

import { normalizeProjection } from "./mongo_utils";

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/mongo/collection_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ Tinytest.add('collection - calling find with a valid readPreference',
// as the cursor options are now private
// You can check on abstract_cursor.ts the exposed public getters
test.equal(
defaultCursor._synchronousCursor._dbCursor.readPreference
defaultCursor._asynchronousCursor._dbCursor.readPreference
.mode,
defaultReadPreference
);
test.equal(
customCursor._synchronousCursor._dbCursor.readPreference.mode,
customCursor._asynchronousCursor._dbCursor.readPreference.mode,
customReadPreference
);
}
Expand All @@ -214,7 +214,7 @@ Tinytest.addAsync('collection - calling find with an invalid readPreference',
);

await test.throwsAsync(async function() {
// Trigger the creation of _synchronousCursor
// Trigger the creation of _asynchronousCursor
await cursor.countAsync();
}, `Invalid read preference mode "${invalidReadPreference}"`);
}
Expand Down
Loading

0 comments on commit 9c4a339

Please sign in to comment.