apache/openwhisk-runtime-nodejs

problems with error handling

Closed this issue ยท 2 comments

The recent PR #95
cause problems in the travis pipeline in core repo: https://travis-ci.org/apache/incubator-openwhisk/builds/447588143

The user should be allowed to on Error return an error object or simple value, that's the contract today
The PR changes this to always make it a string { error: <String>}

Another problem I see this PR always do a console.error() if it contains error.message, this is not ideal as it can leak privacy data into logs, and in some production system eat over their quota.
The user should be in control on what to log or not. we should not force the console.error

I understand that the PR was trying to address #63 I think the real problem is that error native objects were not being serialize.

I propose:

  1. Do not change the current contract, do not constrain the output of the Function to a string.
  2. Handle properly Event type errors object that it serializes and is not empty
  3. Do not console.error, this is user land responsibility domain on what they want to log or not.

Here is reproduce, we should add this to the list of tests to catch this earlier
create a hello.js

function main(){
return new Promise((resolve, reject)=>{
    let myerror = {
        code: 42,
        message: 'where is an error message'
    }
    reject(myerror)
})
}
๐Ÿ‘ $ wsk action update hello hello.js
ok: updated action hello
๐Ÿ‘ $ wsk action invoke hello -r
{
    "error": "[object Object]"
}
> myerror
{ code: 42, message: 'where is an error message' }
> myerror.toString()
'[object Object]'