apache / openwhisk-client-js

JavaScript client library for the Apache OpenWhisk platform
https://openwhisk.apache.org/
Apache License 2.0
83 stars 53 forks source link

blocking invoke that is demoted is not handled correctly #198

Closed rabbah closed 4 years ago

rabbah commented 4 years ago

The action invoke handler for a blocking request is: https://github.com/apache/openwhisk-client-js/blob/3cd025738f740080fc3d7b971f500a977914c568/lib/actions.js#L45-L52

But if the result of the activation is converted to a non-blocking activation, the result is an { activationId } only and this code will fail.

A potential fix:

  invoke (options) {
    options = options || {}
    if (options.blocking && options.result) {
      return super.invoke(options).then(result => {
          if (result.response) {
              return result.response.result
          } else return Promise.reject(result)
      })
    }

    return super.invoke(options)
  }
rabbah commented 4 years ago

Closed by #199.