browserstack/browserstack-local-nodejs

browserstack-local: bs_Local.isRunning() returns undefined

Opened this issue · 5 comments

Issue:
bs_Local.isRunning() is always returns undefined.

Details

My Code:
const browserstackLocal = require('browserstack-local');
const bs_Local = new browserstackLocal.Local();

/* Function to establish local connection */
async newBrowserLocal(browserStackConfig) {
const bsLocalArgs = { key: browserStackConfig.bsKey, forcelocal: 'true' };
await bs_Local.start(bsLocalArgs, async function () {
await console.log('Started BrowserStackLocal');
});
}
await console.log(bs_Local.isRunning());

output:
Started BrowserStackLocal
undefined

Exactly the same error happens to me with the exact same setup aka async function calls. Any suggestion how to solve this? Running the latest version of browserstack-local.

Now it works with following function call:

    const bs_local = new browserstack.Local();
    return new Promise((resolve, reject)=> {
      const config: any = { 'key': 'KEY, 'force': 'true', 'localIdentifier': 'BSTest'};
      bs_local.start(config, (error)=> {
        console.log('Local started');
        if (error) {
          reject(error);
        }
        resolve(bs_local);
      });
    });

Hope this helps!

Thank you @o-hook. This should be fixed along with the related issue #118.

SCG82 commented

Try

bs_Local.startSync(bsLocalArgs);
console.log('Started BrowserStackLocal', bs_Local.isRunning());

+1