ON_REQUEST called twice on launch with global UNHANDLED


#1

Running into an issue where on the launch command, ON_REQUEST is called, followed by UNHANDLED, followed by ON_REQUEST again, followed by LAUNCH. Here’s a code snippet of my app.setHandler

async ON_REQUEST() {
    console.log("ON_REQUEST");
    ...
},
async LAUNCH() {
    console.log("LAUNCH");
    ...
},
async Unhandled() {
    console.log("UNHANDLED");
    ...
},

In the logs I get
ON_REQUEST
UNHANDLED
ON_REQUEST
LAUNCH

I’m confused as to why UNHANDLED is being called when the LAUNCH is able to handle this and very confused as to how one request is causing ON_REQUEST to be called twice.

Any ideas?


#2

A couple of extra findings:

  • This doesn’t occur in the debugger (jovo run), only on the lambda. In the debugger it does do ON_REQUEST followed by LAUNCH
  • Saw there was an update today so I updated to the latest (jovo update) which seems to have broken this.toStateIntent (again only on the lambda, not the debugger)
  • The update has also changed the order of events to be ON_REQUEST, LAUNCH, ON_REQUEST, UNDEFINED
  • this.$request.getIntentName() is returning undefined on both the debugger and the lambda at all points so I assume I am in the launch intent

#3

Note that this is still occurring for me. I refactored the ON_REQUEST code into the LAUNCH and UNDEFINED however they are both still going off

toStateIntent is also not working in either so I’ll have to remove that as well if nobody has any ideas


#4

Hey! This sounds weird. Two things for debugging:

  • Could you send your request JSON so we can take a closer look?
  • What happens if you create a fresh new project and send the same request? Is it still going into Unhandled?

#5

So I think it may have been caused by having an error each time. After removing toStateIntent from the app.js, Only the LAUNCH was handled. Afterwards all other states were handled by UNHANDLED which is what I wanted.

My guess is if LAUNCH gets an exception in the middle, the code thinks it’s been unhandled since we never created a response and it gets sent to UNHANDLED

Still no idea why toStateIntent wasn’t working though


#6

Could you share how you’ve been using toStateIntent in your code?