Skip to content

Promises act odd when debugging in chrome #2286

@RWOverdijk

Description

@RWOverdijk

When enabling Debug in chrome (simulator), using promises acts up for me.

var foo = {
  bar () {
    this.getLocation().then((loc) => {
      console.log(loc);
    });
  },

  getLocation () {
    var p = new Promise((resolve, reject) => {
      navigator.geolocation.getCurrentPosition(position => {
        console.log('going to resolve');
        resolve(position);
      }, error => {
        console.log('going to reject');
        reject(error);
      }, {
        enableHighAccuracy: false,
        timeout           : 20000,
        maximumAge        : 15000
      });
    });

    p.then(position => {
      console.log('called in here');
      return position;
    });

    return p;
  },
};

foo.bar();

Sometimes (when it has to look up the position because timeout has expired) I’m getting "going to resolve” logged but nothing else. No “called in here” and no loc in the method I’m calling this from.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions