Skip to content

Multiple async calls get mixed up #39

@thehunmonkgroup

Description

@thehunmonkgroup

I use the utility function listed below to make individual API calls via this package, with FS as an instance of esl.client():

FreeswitchUtil.prototype.runFreeswitchCommand = function(command, callback, FS) {
  callback = callback ? callback : function() {};
  FS = FS ? FS : this.FS;
  this.logger.debug(format("Running command '%s'", command));
  FS.api(command)
  .then(function(res) {
    this.logger.debug(format("Command '%s' result headers: %s", command, JSON.stringify(res.headers)));
    this.logger.debug(format("Command '%s' result body: %s", command, res.body));
    callback(null, res.body);
  }.bind(this))
  .catch(function(error) {
    if (_.isObject(error.res)) {
      this.logger.error(format("Command '%s' error: %s", command, error.res.body));
      callback(error.res.body, null);
    }
    else {
      this.logger.error(format("Command '%s' error: %s", command, JSON.stringify(error)));
      callback(error, null);
    }
  }.bind(this));
}

When I put the system under load with a lot of async calls happening, I see logging output that looks like certain commands get overwritten by other incoming commands:

debug: Command 'conference 585 vid-res-id 18 3' result body: Non-Existant ID 15

The ID in that response should not be 15, as I'm sending 18 in the command. The command variable is scoped to my function, so it doesn't make any sense to me that it's getting overwritten in the function itself.

Curious if I've set things up wrong in my support function, or if this package has some issue handling lots of simultaneous calls, or if it's some bug in FreeSWITCH?

FYI, running version 4.0.1 of this package, as it seems to be the newest that runs on node 10.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions