[SOLVED] Http deprecated error

TLDR: This post is not about http deprecated error, but just an issue with my code. The problem has been solved. If you are using matb33:collection-hooks and konecty:user-presence, this post might be of interest.


I’m having some trouble upgrading my code to Meteor2.0
I bumped into this error, after trying to use the loginwithgoogle:

D20210205-16:49:56.195(8) (http.js:169) The http package has been deprecated, please migrate to the fetch package and new web standards.
D20210205-16:50:02.346(8) (http.js:169) The http package has been deprecated, please migrate to the fetch package and new web standards.
D20210205-16:50:02.454(8) (http.js:169) The http package has been deprecated, please migrate to the fetch package and new web standards.
I20210205-16:50:02.787(8)? Exception while invoking method 'login' MongoError: '$set' is empty. You must specify a field like so: {$set: {<field>: ...}}
I20210205-16:50:02.788(8)?     at Function.create (/Users/HafizFamily/.meteor/packages/npm-mongo/.3.8.1.yf5rmr.r2ea++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/mongodb/lib/core/error.js:57:12)
I20210205-16:50:02.788(8)?     at toError (/Users/HafizFamily/.meteor/packages/npm-mongo/.3.8.1.yf5rmr.r2ea++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/mongodb/lib/utils.js:123:22)
I20210205-16:50:02.788(8)?     at /Users/HafizFamily/.meteor/packages/npm-mongo/.3.8.1.yf5rmr.r2ea++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/mongodb/lib/operations/common_functions.js:379:39
I20210205-16:50:02.788(8)?     at /Users/HafizFamily/.meteor/packages/npm-mongo/.3.8.1.yf5rmr.r2ea++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/mongodb/lib/core/connection/pool.js:405:18
I20210205-16:50:02.789(8)?     at processTicksAndRejections (internal/process/task_queues.js:79:11)**strong text**

The code works on the last version of Meteor 1.12.1, but after i’ve upgraded to Meteor 2.0, the error occurs.
I understand that the http packages has been deprecated, but I have not use http package anywhere as of right now. The app that I am developing is still in its early stages. I’ve only had few public facing pages, and is now trying to include login/logout functionality. The app runs fine before adding the more configurations to Accounts for login logout logic.

Here’s my main.js file:

import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import dayjs from 'dayjs';
import { Roles } from 'meteor/alanning:roles';

//import collections
import { UserProfiles } from '../imports/api/UserProfiles';

Meteor.startup(() => {
    //rebooting Accounts Login Services by wiping the Google services clean...
        service: "google"
    //... then register a new Accounts Login Services upon starting up.
      { service: 'google' },
        $set: {
          clientId: 'xxxxx.apps.googleusercontent.com',
          loginStyle: 'popup',
          secret: 'xxxx'

    //Accounts.config({restrictCreationByEmailDomain: 'xxx.com'});
    var checkEmailAgainstAllowed = function(email) {
        //var allowedDomains = ['mycompanydomain.com'];
        var allowedEmails = ['xxx.com','yyy.com', 'zzz.com'];
        //var domain = email.replace(/.*@/,'').toLowerCase();
        email = email.toLowerCase();
        return allowedEmails.includes(email);
        restrictCreationByEmailDomain: function(email) {
        if (!email) {
            throw new Meteor.Error(403,'This email address is not allowed');
        if (!checkEmailAgainstAllowed(email)) {
            throw new Meteor.Error(403,'Opps! Thank you for your interest, but your email address is not listed in our beta testers database.');
        return true;

    // Listen for new connections, login, logoff and application exit to manage user status and register methods to be used by client to set user status and default status
    // Active logs for every changes
    // Listen for changes in UserSessions and Meteor.users to set presence status based on active connections to user collection...
    //... then apply their status to the corresponding UserProfiles document
    Meteor.users.after.update(function (userId, doc, fieldNames, modifier) {
          owner : doc._id
        }, {
          $set: {
            status : doc.status
        }, {multi: true})

    Meteor.users.after.insert(function (userId, doc) {

        if (typeof(doc.services.google) != "undefined") {
            //custom assign a specific role for XXX, the creator
            if(doc.services.google.email === 'xxx.com'){
                Roles.createRole('superuser', {unlessExists: true});
                Roles.addUsersToRoles(doc._id, ['superuser']);
                doc.roles = ['superuser'];
                doc.activated = 1;
                doc.status = 'offline';
            } else {
                Roles.createRole('student', {unlessExists: true});
                Roles.addUsersToRoles(doc._id, ['student']);
                doc.roles = ['student']; 
                doc.status = 'offline';
                doc.activated = 1;
                owner: doc._id,
                firstTimeLogin: true,
                ... //shortened the code


    //Push information to new collection in server
        if (options.profile)
        user.profile = options.profile;
        user._id = Meteor.users._makeNewID();
        // Use provided profile in options, or create an empty object
        user.profile = options.profile;
        // Assigns first and last names to the newly created user object
        user.profile.name = options.profile.name;
        return user;

I’ve tried installing fetch packages as per suggested in the doc but without understanding what’s triggered the error, I can’t troubleshot it.

Can anyone point me to the right direction. A Meteor newbie here.

Additional info: When I check the mongodb using robo3T, the login function appears to be successful as new user has been created, but the error persists.

The error is not related to the HTTP deprecation. The http deprecation is due to core packages still using it and there are fixes going on for this.

As of your error, it seems to be triggered, because one of your Mongo updates passes somewhere an empty $set. Is there some more stack trace to show for the ereror or just the 5 lines?

1 Like

Yes. that’s all.
I think i’ve singled out the source of the error.
It’s got to do with this codes:

… because after i commented out that code block, the login works fine.
But why is this happening? The code runs fine before this.

I’ve figured it out.

The matb33:collection-hooks fired up before konecty:user-presence were able to inject status into the user collection. so i fixed the code by adding if around the code like so:

Meteor.users.after.update(function (userId, doc, fieldNames, modifier) {
                owner : doc._id
              }, {
                $set: {
                  status : doc.status
              }, {multi: true})
1 Like