DEV Community

Cover image for Prepare your Meteor.js project for the big 3.0 release!

Prepare your Meteor.js project for the big 3.0 release!

Jan Küster on November 01, 2023

Meteor.js 3.0 is an upcoming major release with lots of breaking changes. The platform is moving away from Fibers to use Node's native async await ...
Collapse
 
storytellercz profile image
Jan Dvorak

For the count, the migration should be more advanced, from documentation:

This method is deprecated since MongoDB 4.0; see Collection.countDocuments and Collection.estimatedDocumentCount for a replacement.

Collapse
 
jankapunkt profile image
Jan Küster

Thanks for the hint, I will update this one

Collapse
 
balines_f053b1282 profile image
Carlos Alvidrez

Trying to use the ValidationMethod override, but stomped with this error... not sure if the "analyze" method requires another import?

Exception while invoking method 'XXX' ReferenceError: analyze is not defined
Enter fullscreen mode Exit fullscreen mode

Thanks!

Collapse
 
jankapunkt profile image
Jan Küster

Did you use the jkuester:migration-helper package or did you used the code from this article?

Collapse
 
balines_f053b1282 profile image
Carlos Alvidrez

Hi! Both... here's the snippet. Puzzled because I read the code and figure out a couple of imports might be required... but the helper still outputs to the console that my method is not async yet.

//import { getLocation, analyze } from 'meteor/jkuester:migration-helper';
import { checkAsyncMixin } from 'meteor/jkuester:migration-helper';
import { getLocation } from 'meteor/jkuester:migration-helper';
import { analyze } from 'meteor/jkuester:migration-helper';

const originalExec = ValidatedMethod.prototype._execute;
ValidatedMethod.prototype._execute = function (...args) {
    const self = this;
    console.log("--> self.name:", self.name);
    //console.log("getLocation():", getLocation());
    analyze({
        name: self.name,
        location: getLocation(),
        type: 'ValidatedMethod',
        fn: self.run
    });
    return originalExec.call(self, ...args);
};
Enter fullscreen mode Exit fullscreen mode

And this is the method code (very simple case):

export const pubVersesPaginationPassageRateLimiter = new ValidatedMethod({
    name: 'pubVersesPaginationPassageRateLimiter',
    validate: new SimpleSchema({
        source: { type: String },
    }).validator(),
    async run({}) {
        return true;
    }
});
Enter fullscreen mode Exit fullscreen mode

Any advice will be appreciated... working hard on refactoring my webapp to migrate to v3 ASAP.

Cheers

Thread Thread
 
jankapunkt profile image
Jan Küster

Thanks for the examples I will try to reproduce this. In the meantime, there has also been an eslint-plugin being developed by quave, which can also help you to detect parts that need migration (it is specifically designed for this task):

github.com/quavedev/eslint-plugin

Will get back to you when I find the cause for the issue.

Thread Thread
 
balines_f053b1282 profile image
Carlos Alvidrez

Thank you!

Collapse
 
balines_f053b1282 profile image
Carlos Alvidrez

Also, wanted to pick someone's brain around how to fix these issues... must I find new packages for these? (debugging results from the suggested migration helper package):

Deprecated (Publication): meteor_autoupdate_clientVersions is not async, consider migrating now.
  => at packages/autoupdate/autoupdate_server.js:109:8

Deprecated (Publication): _roles is not async, consider migrating now.
  => at module (packages/alanning:roles/roles/roles_server.js:30:8)

Deprecated (Method): slingshot/uploadRequest is not async, consider migrating now.
  => at packages/edgee_slingshot.js:404:8

Deprecated: Collection.findOne needs to be migrated to findOneAsync in collection "__dummy_coll_4MqSQRvCKueAzPu9m"!
=> at module (packages/mdg:meteor-apm-agent/lib/hijack/meteorx.js:34:12)
Enter fullscreen mode Exit fullscreen mode
Collapse
 
balines_f053b1282 profile image
Carlos Alvidrez

Another one:

Deprecated: Collection.update needs to be migrated to updateAsync in collection "meteor_accounts_loginServiceConfiguration"!
=> at Collection.upsert (packages/mongo/collection.js:785:17)
Enter fullscreen mode Exit fullscreen mode
Collapse
 
balines_f053b1282 profile image
Carlos Alvidrez

Is there a pagination package you'd recommend to use for Meteor 3?
I am using this one but it's not been maintained and JKuster's migration helper reports the underlying methods not being async.

github.com/Kurounin/Pagination/tre...

Collapse
 
balines_f053b1282 profile image
Carlos Alvidrez

I believe this library was causing me trouble as it trips the migration helper... as soon as I removed it, all my methods stopped reporting not being async.

mdg:meteor-apm-agent

@jankapunkt FYI