简体   繁体   中英

OpenWhisk/Node — Promise Is Not Resolving

I've tested a reddit bot locally for a while now, and gotten it working locally. So now I'm trying to invoke it on OpenWhisk. The line where my troubles seem to come up is:

r.getInbox( {"filter":"mentions", "append":false } ).then( newMentions, console.err );

newMentions is never triggered. I've made the first line in it a console.log, and I've replaced newMentions with console.log.

console.logs before and after this line get called just fine, and getInbox works fine on my local machine and should work just fine here. I'm not getting any error anywhere, even from console.err in the above line.

So my current guess is that my OpenWhisk instance somehow ends before getInbox can resolve. Is that right? I have it set to 60s/512mb, and it's not taking anywhere near 60s, and I can't imagine it takes up 512mb. So... Do I need to manually force OpenWhisk to wait for the promise to resolve? How would I do that? Or is there some other error I'm not seeing?

To be clear: I'm using snoowrap for reddit. r is a proper snoowrap object, and getInbox is a snoowrap function that I'm pretty sure I'm using correctly, which returns a promise for json data representing an inbox. And again, even if it were empty, newMentions should still be called, right?

return the promise to the main function

function main(){
  return r.getInbox( {"filter":"mentions", "append":false } ).then( newMentions, console.error );
}

this way OpenWhisk will wait on the Promise

make sure your resolve function newMentions or reject function returns a JSON object, it will be the result of the Action

Also console.err is not a function is console.error

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM