Skip to content

bug: when called subsequently, Geolocation.getCurrentPosition() doesn't resolve#46

Description

@aprat84

Bug Report

Capacitor Version

npx cap doctor output:

馃拪   Capacitor Doctor  馃拪 
Latest Dependencies:
  @capacitor/cli: 2.1.2
  @capacitor/core: 2.1.2
  @capacitor/android: 2.1.2
  @capacitor/electron: 2.1.2
  @capacitor/ios: 2.1.2
Installed Dependencies:
  @capacitor/ios not installed
  @capacitor/electron not installed
  @capacitor/cli 2.1.2
  @capacitor/android 2.1.2
  @capacitor/core 2.1.2
[success] Android looking great! 馃憣

Affected Platform(s)

  • Android
  • iOS
  • Electron
  • Web

Current Behavior

If multiple parallel calls to Geolocation.getCurrentPosition() are made, only last one returns any result, success or error.

alt text

Expected Behavior

Every call to Geolocation.getCurrentPosition() should have it's promise fullfilled or rejected.
This shoud be the way, besides what the plugin does internally (which native API uses, cached position, ...)

Sample Code or Sample Application Repo

const params = {
    enableHighAccuracy: true,
    maximumAge: 20000,
    timeout: 50,
};

console.log('position 1 start')
Capacitor.Plugins.Geolocation.getCurrentPosition(params).then(
  position => console.log('position 1', position), 
  error => console.error('position 1 error', error)
);
console.log('position 2 start')
Capacitor.Plugins.Geolocation.getCurrentPosition(params).then(
  position => console.log('position 2', position), 
  error => console.error('position 2 error', error)
);
console.log('position 3 start')
Capacitor.Plugins.Geolocation.getCurrentPosition(params).then(
  position => console.log('position 3', position), 
  error => console.error('position 3 error', error)
);
console.log('position 4 start')
Capacitor.Plugins.Geolocation.getCurrentPosition(params).then(
  position => console.log('position 4', position), 
  error => console.error('position 4 error', error)
);

Reproduction Steps

  • Create a new test project based on capacitor starter npx @capacitor/cli create
  • Add the example code below to any JS file/script (I put it in js/capacitor-welcome.js file)

Other Technical Details

npm --version output: 6.14.4
node --version output: v12.17.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions