Search code examples
javascriptes6-promiseokta

Nodejs script not ending


using the client.getUser(:id|:login) nodejs example at https://developer.okta.com/okta-sdk-nodejs/jsdocs/, I can successfully get the user details, however he script doesn’t “end” it just hangs after returning the user Information.

const okta = require('@okta/okta-sdk-nodejs');

const client = new okta.Client({
  orgUrl: 'https://dev-1234.oktapreview.com/'
  token: 'xYzabc'    // Obtained from Developer Dashboard
});

client.getUser('[email protected]')
.then(user => {
  console.log(user);
});

Do I need to “end” the connection or the promise or something?


Solution

  • Check the issue here: =)

    https://github.com/okta/okta-sdk-nodejs/issues/86

    Issue definitely in the sdk itself, not in the script you are running.

    Looks like issue is here https://github.com/okta/okta-sdk-nodejs/blob/master/src/memory-store.js#L22

    Next workaround:

    const okta = require('@okta/okta-sdk-nodejs');
    const MemoryStore = require('@okta/okta-sdk-nodejs/src/memory-store');
    
    const client = new okta.Client({
      cacheStore: new MemoryStore({
        expirationPoll:null
      }),
      orgUrl: 'https://dev-160519.oktapreview.com',
      token: '00s8yW7KiYpCOFRc8USWZWS4FgvQPSrnRli9QFFzZG',    // Obtained from Developer Dashboard,
    });
    
    client.getUser('[email protected]')
    .then(user => {
      console.log(user);
    }).catch(console.error);
    

    works as expected