Skip to content

"Error: Callback was already called" when using "near" filter #285

Description

@bachirelkhoury

Given this simple geolocation query, when I include the "near" query I'm getting this error:

/node_modules/mongodb/lib/utils.js:98
    process.nextTick(function() { throw err; });
                                  ^

Error: Callback was already called.
    at /node_modules/async/dist/async.js:844:36
    at /node_modules/async/dist/async.js:3676:17
    at /node_modules/async/dist/async.js:339:31
    at /node_modules/strong-remoting/lib/remote-objects.js:694:7
    at execStack (/node_modules/strong-remoting/lib/remote-objects.js:490:9)
    at RemoteObjects.execHooks (/node_modules/strong-remoting/lib/remote-objects.js:497:10)
    at interceptInvocationErrors (/node_modules/strong-remoting/lib/remote-objects.js:693:10)
    at /node_modules/loopback-phase/node_modules/async/lib/async.js:148:21
    at /node_modules/loopback-phase/node_modules/async/lib/async.js:148:21
    at /node_modules/loopback-phase/node_modules/async/lib/async.js:148:21

Can't find the root cause of this.

This code works:

user.find({}, function(err, users) {
        if (err) {
          return cb(err);
        }
        return cb(null, users);
    });
  };

This one below throws the error. I've placed a breakpoint in the callback, and it does get called twice internally. Couldn't trace it too far so not sure what's firing this.

user.find({
      where: {
        location: {near: here, maxDistance: distance, unit: 'meters'}
      }
    }, function(err, users) {
        if (err) {
          return cb(err);
        }
        return cb(null, users);
    });
  };

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions