rannn505 / child-shell

Node.js bindings 🔗 for shell
http://rannn505.github.io/child-shell/
MIT License
301 stars 71 forks source link

invoke promise not always executed #134

Closed DarkLite1 closed 2 years ago

DarkLite1 commented 3 years ago

We have a strange issue where the PowerShell code seems to be executed the then, catch and finally on invoke are not. Our app has one button and when clicked it triggers this function:

export const getComputerDetails = async (name: string) => {
  console.log(`getComputerDetails called with ${name}`)

  const ps = new shell({
    executionPolicy: 'Bypass',
    noProfile: true,
    verbose: true,
  })

  await ps.addCommand('"hello world"')

  ps.invoke()
    .then((output) => {
      console.log('invoke')
      console.log(output)
    })
    .catch((err) => {
      console.log('catch')
      console.log(err)
      void ps.dispose()
    })
    .finally(() => { console.log('finally') })
}

On some clicks (not all) the then, catch or finally on invoke are not executed.:

image

We see that node-powershell received some updates regarding this issue. Would it be possible to release these to npm so we can use the package in production?

Thank you for your help.