Seeing error after updating METEOR to 1.6.1.3 from 1.4.2

(node:46084) UnhandledPromiseRejectionWarning: TypeError: LocalCollection._removeDollarOperators is not a function
W20180810-14:56:08.532(-7)? (STDERR) at simulateUpsertWithInsertedId (packages/mongo/mongo_driver.js:683:39)
W20180810-14:56:08.532(-7)? (STDERR) at MongoConnection._update (packages/mongo/mongo_driver.js:554:7)
W20180810-14:56:08.532(-7)? (STDERR) at MongoConnection. (packages/meteor.js:258:21)
W20180810-14:56:08.533(-7)? (STDERR) at MongoConnection.(anonymous function) [as update] (packages/mongo/mongo_driver.js:782:49)
W20180810-14:56:08.533(-7)? (STDERR) at Object.collection.(anonymous function) [as update] (packages/matb33_collection-hooks.js:133:23)
W20180810-14:56:08.533(-7)? (STDERR) at Mongo.Collection.update (packages/mongo/collection.js:589:29)
W20180810-14:56:08.533(-7)? (STDERR) at Mongo.Collection.upsert (packages/mongo/collection.js:676:15)
W20180810-14:56:08.533(-7)? (STDERR) at packages/matb33_collection-hooks.js:710:21
W20180810-14:56:08.533(-7)? (STDERR) at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
W20180810-14:56:08.533(-7)? (STDERR) at Object.directOp (packages/matb33_collection-hooks.js:47:27)
W20180810-14:56:08.534(-7)? (STDERR) at Mongo.Collection. (packages/matb33_collection-hooks.js:709:31)
W20180810-14:56:08.534(-7)? (STDERR) at Mongo.Collection.collection.(anonymous function) [as upsert] (packages/matb33_collection-hooks.js:146:21)
W20180810-14:56:08.534(-7)? (STDERR) at packages/poetic:accounts-apple-connect/server/api-create-token-and-redirect.js:43:16
W20180810-14:56:08.534(-7)? (STDERR) at /Users/m_712199/.meteor/packages/promise/.0.10.1.1820vuk.0x03g++os+web.browser+web.cordova/npm/node_modules/meteor-promise/fiber_pool.js:43:40

Need help on this ā€¦
Thanks

Probably need more information to resolve this one.

Looks like it is something in the poetic package - that package - specifically whatever it is doing at
poetic:accounts-apple-connect/server/api-create-token-and-redirect.js:43:16

Iā€™d be checking for any updates on that package.

Sharing the source code which is triggering the error would also be helpful.

Failing that you may need to reduce this to a replicatable case so folks here can help you to debug/investigate. The error message by itself is not a lot to work with.

As an thought - I recall in our earlier discussion you mentioned editing the mongodb package.js to change its internal version number to get around an error message about incompatible versions.
I hope you have reverted that change as otherwise it would leave you with an old version of the mongodb package which the version checker would believe is the right version. This could cause weird incompatibility errors like this one. Just mentioning in case it might be the issue.

1 Like

This is is the code where LocalCollection is
var simulateUpsertWithInsertedId = function (collection, selector, mod,
isModify, options, callback) {
// STRATEGY: First try doing a plain update. If it affected 0 documents,
// then without affecting the database, we know we should probably do an
// insert. We then do a conditional insert that will fail in the case
// of a race condition. This conditional insert is actually an
// upsert-replace with an _id, which will never successfully update an
// existing document. If this upsert fails with an error saying it
// couldnā€™t change an existing _id, then we know an intervening write has
// caused the query to match something. We go back to step one and repeat.
// Like all ā€œoptimistic writeā€ schemes, we rely on the fact that itā€™s
// unlikely our writes will continue to be interfered with under normal
// circumstances (though sufficiently heavy contention with writers
// disagreeing on the existence of an object will cause writes to fail
// in theory).

var newDoc;
// Run this code up front so that it fails fast if someone uses
// a Mongo update operator we donā€™t support.
if (isModify) {
// Weā€™ve already run replaceTypes/replaceMeteorAtomWithMongo on
// selector and mod. We assume it doesnā€™t matter, as far as
// the behavior of modifiers is concerned, whether _modify
// is run on EJSON or on mongo-converted EJSON.
var selectorDoc = LocalCollection._removeDollarOperators(selector);

newDoc = selectorDoc;

// Convert dotted keys into objects. (Resolves issue #4522).
_.each(newDoc, function (value, key) {
  var trail = key.split(".");

  if (trail.length > 1) {
    //Key is dotted. Convert it into an object.
    delete newDoc[key];

    var obj = newDoc,
        leaf = trail.pop();

    // XXX It is not quite certain what should be done if there are clashing
    // keys on the trail of the dotted key. For now we will just override it
    // It wouldn't be a very sane query in the first place, but should look
    // up what mongo does in this case.

    while ((key = trail.shift())) {
      if (typeof obj[key] !== "object") {
        obj[key] = {};
      }

      obj = obj[key];
    }

    obj[leaf] = value;
  }
});

LocalCollection._modify(newDoc, mod, {isInsert: true});

} else {
newDoc = mod;
}

var insertedId = options.insertedId; // must exist
var mongoOptsForUpdate = {
safe: true,
multi: options.multi
};
var mongoOptsForInsert = {
safe: true,
upsert: true
};

var tries = NUM_OPTIMISTIC_TRIES;

var doUpdate = function () {
triesā€“;
if (! tries) {
callback(new Error(ā€œUpsert failed after " + NUM_OPTIMISTIC_TRIES + " tries.ā€));
} else {
collection.update(selector, mod, mongoOptsForUpdate,
bindEnvironmentForWrite(function (err, result) {
if (err) {
callback(err);
} else if (result && result.result.n != 0) {
callback(null, {
numberAffected: result.result.n
});
} else {
doConditionalInsert();
}
}));
}
};

var doConditionalInsert = function () {
var replacementWithId = _.extend(
replaceTypes({_id: insertedId}, replaceMeteorAtomWithMongo),
newDoc);
collection.update(selector, replacementWithId, mongoOptsForInsert,
bindEnvironmentForWrite(function (err, result) {
if (err) {
// figure out if this is a
// ā€œcannot change _id of documentā€ error, and
// if so, try doUpdate() again, up to 3 times.
if (MongoConnection._isCannotChangeIdError(err)) {
doUpdate();
} else {
callback(err);
}
} else {
callback(null, {
numberAffected: result.result.upserted.length,
insertedId: insertedId,
});
}
}));
};

doUpdate();
};

./meteor/packages

meteor-base@1.3.0 # Packages every Meteor app needs to have
mobile-experience@1.0.5 # Packages for a great mobile UX
mongo@1.4.2 # The database Meteor supports right now
reactive-var@1.0.11 # Reactive variable for tracker
jquery@1.11.10 # Helpful client-side library
tracker@1.1.3 # Meteorā€™s client-side reactive programming library

standard-minifier-css@1.4.0 # CSS minifier run for production mode
standard-minifier-js@2.3.1 # JS minifier run for production mode
es5-shim@4.7.0 # ECMAScript 5 compatibility for older browsers.
ecmascript@0.10.6 # Enable ECMAScript2015+ syntax in app code
shell-server@0.3.1 # Server-side component of the meteor shell command

service-configuration@1.0.11
accounts-base@1.4.2
static-html
react-meteor-data
dburles:collection-helpers
dburles:mongo-collection-instances
matb33:collection-hooks
themeteorchef:bert
poetic:apple-es-db-adapter
poetic:accounts-apple-connect
poetic:apple-es-db-logger
http@1.4.0
poetic:meteor-react-guard@2.2.0
ground:db@2.0.0-rc.7
dynamic-import

./Versions
accounts-base@1.4.2
allow-deny@1.1.0
autoupdate@1.4.0
babel-compiler@7.0.9
babel-runtime@1.2.2
base64@1.0.10
binary-heap@1.0.10
blaze@2.3.2
blaze-tools@1.0.10
boilerplate-generator@1.4.0
caching-compiler@1.1.9
caching-html-compiler@1.0.7
callback-hook@1.1.0
check@1.3.0
dburles:collection-helpers@1.1.0
dburles:mongo-collection-instances@0.3.5
ddp@1.4.0
ddp-client@2.3.2
ddp-common@1.4.0
ddp-rate-limiter@1.0.7
ddp-server@2.1.2
deps@1.0.12
diff-sequence@1.1.0
dynamic-import@0.3.0
ecmascript@0.10.6
ecmascript-runtime@0.5.0
ecmascript-runtime-client@0.6.2
ecmascript-runtime-server@0.5.0
ejson@1.1.0
es5-shim@4.7.0
fortawesome:fontawesome@4.4.0_1
fourseven:scss@3.8.1
geojson-utils@1.0.10
ground:db@2.0.0-rc.7
hot-code-push@1.0.4
html-tools@1.0.11
htmljs@1.0.11
http@1.4.0
id-map@1.1.0
jquery@1.11.10
lai:collection-extensions@0.2.1_1
launch-screen@1.1.1
livedata@1.0.18
localstorage@1.2.0
logging@1.1.19
matb33:collection-hooks@0.8.4
meteor@1.8.2
meteor-base@1.3.0
minifier-css@1.3.0
minifier-js@2.3.5
minimongo@1.4.3
mobile-experience@1.0.5
mobile-status-bar@1.0.14
modules@0.11.3
modules-runtime@0.9.1
mongo@1.4.2
mongo-id@1.0.6
npm-mongo@2.2.33
observe-sequence@1.0.16
ordered-dict@1.1.0
poetic:accounts-apple-connect@0.0.1
poetic:apple-es-db-adapter@0.0.1
poetic:apple-es-db-logger@0.0.1
poetic:meteor-react-guard@2.3.0
promise@0.10.1
raix:eventemitter@0.1.3
raix:eventstate@0.0.4
random@1.1.0
rate-limit@1.0.8
react-meteor-data@0.2.9
reactive-dict@1.2.0
reactive-var@1.0.11
reload@1.2.0
retry@1.1.0
routepolicy@1.0.12
server-render@0.3.1
service-configuration@1.0.11
session@1.1.7
shell-server@0.3.1
shim-common@0.1.0
socket-stream-client@0.1.0
spacebars@1.0.13
spacebars-compiler@1.1.1
standard-minifier-css@1.4.0
standard-minifier-js@2.3.3
static-html@1.1.13
templating@1.2.14
templating-tools@1.1.1
themeteorchef:bert@2.1.1
tmeasday:check-npm-versions@0.2.0
tracker@1.1.3
underscore@1.0.10
url@1.2.0
webapp@1.5.0
webapp-hashing@1.0.9

./package.js
// XXX We should revisit how we factor MongoDB support into (1) the
// server-side node.js driver [which you might use independently of
// livedata, after all], (2) minimongo [ditto], and (3) Collection,
// which is the class that glues the two of them to Livedata, but also
// is generally the ā€œpublic interface for newbiesā€ to Mongo in the
// Meteor universe. We want to allow the components to be used
// independently, but we donā€™t want to overwhelm the user with
// minutiae.

Package.describe({
summary: ā€œAdaptor for using MongoDB and Minimongo over DDPā€,
version: ā€˜1.4.2ā€™
});

Npm.depends({
ā€œmongodb-uriā€: ā€œ0.9.7ā€
});

Npm.strip({
mongodb: [ā€œtest/ā€]
});

Package.onUse(function (api) {
api.use(ā€˜npm-mongoā€™, ā€˜serverā€™);
api.use(ā€˜allow-denyā€™);

api.use([
ā€˜randomā€™,
ā€˜ejsonā€™,
ā€˜underscoreā€™,
ā€˜minimongoā€™,
ā€˜ddpā€™,
ā€˜trackerā€™,
ā€˜diff-sequenceā€™,
ā€˜mongo-idā€™,
ā€˜checkā€™,
ā€˜ecmascriptā€™
]);

// Binary Heap data structure is used to optimize oplog observe driver
// performance.
api.use(ā€˜binary-heapā€™, ā€˜serverā€™);

// Allow us to detect ā€˜insecureā€™.
api.use(ā€˜insecureā€™, {weak: true});

// Allow us to detect ā€˜autopublishā€™, and publish collections if itā€™s loaded.
api.use(ā€˜autopublishā€™, ā€˜serverā€™, {weak: true});

// Allow us to detect ā€˜disable-oplogā€™, which turns off oplog tailing for your
// app even if itā€™s configured in the environment. (This package will be
// probably be removed before 1.0.)
api.use(ā€˜disable-oplogā€™, ā€˜serverā€™, {weak: true});

// defaultRemoteCollectionDriver gets its deployConfig from something that is
// (for questionable reasons) initialized by the webapp package.
api.use(ā€˜webappā€™, ā€˜serverā€™, {weak: true});

// If the facts package is loaded, publish some statistics.
api.use(ā€˜factsā€™, ā€˜serverā€™, {weak: true});

api.use(ā€˜callback-hookā€™, ā€˜serverā€™);

// Stuff that should be exposed via a real API, but we havenā€™t yet.
api.export(ā€˜MongoInternalsā€™, ā€˜serverā€™);
// For tests only.
api.export(ā€˜MongoTestā€™, ā€˜serverā€™, {testOnly: true});
api.export(ā€œMongoā€);

api.addFiles([ā€˜mongo_driver.jsā€™, ā€˜oplog_tailing.jsā€™,
ā€˜observe_multiplex.jsā€™, ā€˜doc_fetcher.jsā€™,
ā€˜polling_observe_driver.jsā€™,ā€˜oplog_observe_driver.jsā€™],
ā€˜serverā€™);
api.addFiles(ā€˜local_collection_driver.jsā€™, [ā€˜clientā€™, ā€˜serverā€™]);
api.addFiles(ā€˜remote_collection_driver.jsā€™, ā€˜serverā€™);
api.addFiles(ā€˜collection.jsā€™, [ā€˜clientā€™, ā€˜serverā€™]);
api.addFiles(ā€˜connection_options.jsā€™, ā€˜serverā€™);
});

Package.onTest(function (api) {
api.use(ā€˜mongoā€™);
api.use(ā€˜checkā€™);
api.use([ā€˜tinytestā€™, ā€˜underscoreā€™, ā€˜test-helpersā€™, ā€˜ejsonā€™, ā€˜randomā€™,
ā€˜ddpā€™, ā€˜base64ā€™]);
// XXX test order dependency: the allow_tests ā€œpartial allowā€ test
// fails if it is run before mongo_livedata_tests.
api.addFiles(ā€˜mongo_livedata_tests.jsā€™, [ā€˜clientā€™, ā€˜serverā€™]);
api.addFiles(ā€˜upsert_compatibility_test.jsā€™, ā€˜serverā€™);
api.addFiles(ā€˜allow_tests.jsā€™, [ā€˜clientā€™, ā€˜serverā€™]);
api.addFiles(ā€˜collection_tests.jsā€™, [ā€˜clientā€™, ā€˜serverā€™]);
api.addFiles(ā€˜observe_changes_tests.jsā€™, [ā€˜clientā€™, ā€˜serverā€™]);
api.addFiles(ā€˜oplog_tests.jsā€™, ā€˜serverā€™);
api.addFiles(ā€˜doc_fetcher_tests.jsā€™, ā€˜serverā€™);
});

This is only happening when i am trying to login, on starting server no errors are thrown

This is not the mongodb package file from the Meteor 1.6.1.3 release.

Snippet from your mongodb package file:

Compare this to the release mongodb package version:

Release version (snippet):

Package.onUse(function (api) {
  api.use('npm-mongo', 'server');
  api.use('allow-deny');

  api.use([
    'random',
    'ejson',
    'minimongo',
    'ddp',
    'tracker',
    'diff-sequence',
    'mongo-id',
    'check',
    'ecmascript',
    'mongo-dev-server',
  ]);

  api.use('underscore', 'server');

  // Binary Heap data structure is used to optimize oplog observe driver
  // performance.
  api.use('binary-heap', 'server');

Comparing the two - yours is missing the separate:
api.use(ā€˜underscoreā€™, ā€˜serverā€™);
line. (I realise the underscore package is included in the line above - however I am simply trying to determine if you are actually using the ā€œreleaseā€ version of the package - the file compare suggests not).

I am not sure where your mongodb has come from exactly - but it appears it is not the release version of the package.

I would recommend removing and re-adding the package using the command line (or just delete the mongodb line from your package file and start your app - then add back the mongodb@1.4.2 line to packages).

I also note that poetic also have a fork of the mongo package - GitHub - poetic/mongo: A fork of meteor mongo package - so it is possible that they have added some custom behaviour to mongo that the other poetic package that you are using in your app is dependent on. I am not familiar with the other poetic package in your app - this is just something I would be checking.

Hope this helps in your debugging efforts.

Steve

1 Like