alexa / alexa-skills-kit-sdk-for-nodejs

The Alexa Skills Kit SDK for Node.js helps you get a skill up and running quickly, letting you focus on skill logic instead of boilerplate code.
Apache License 2.0
3.12k stars 733 forks source link

Alexa developer console hangs when returning response from local debugger #660

Open jhonj98 opened 3 years ago

jhonj98 commented 3 years ago

Hi everyone,

Please can you help me with the following issue:

I'm using ask-sdk-local-debug for debugging my skill code, I normally test it without debugging using my lambda function deployed in amazon lambda, but now I want to debug my skill code, I'm using VS Code, when I launch my skill from the developer console testing, everythings seem to run ok, even I can see my debug starting in VS Code, with the information in local console too, so far so good, the thing is that never get a response and if I see the local console log there was a response, but this never gets to the developer console. here the screenshots

image

image

After a few seconds I see a time_out error in the local debug console log with the error "An exception occurred while dispatching the request to the skill".

image

image

I hope someone can help me.

Thank you in advanced.

Jhon Jairo.

ShenChen93 commented 3 years ago

Hi @jhonj98 ,

Thanks for using our SDK and the new local debug feature. For the timeout error, it's as expected as alexa service will timeout if no response is returned after a while(If you are using breakpoint, the response will be hold and service side will report this error). But it seems there's no breakpoint hit based on your screen cut. I need to investigate why response is not send back to the service. Could you please provide us with the skill id ?

Thanks, Shen

jhonj98 commented 3 years ago

Hello @ShenChen-Amazon ,

Thanks for your fast reply, the skill id is amzn1.ask.skill.2b8bf215-1cb4-4a60-adc6-ff7b4ab2bcce, the language of the skill is es_MX. And yes, there is no break point in my code.

Kind regards.

Jhon Jairo.

sattpat commented 3 years ago

Hi @jhonj98. Thanks for reporting this issue. Could you rerun this error scenario and notify us on this ticket as soon as you do so?

jhonj98 commented 3 years ago

Hi @sattpat , I tested again the same scenario and the result is the same, no response yet in the developer console and timeout error in local console log.

Thank you.

Jhon Jairo.

sattpat commented 3 years ago

And just to make sure, if you were to stop debugging, does the skill interaction work against the configured lambda/https endpoint?

jhonj98 commented 3 years ago

Yes! if I stop the debugging, and restart my skill testing in the developer console, the skill returns working with my configured lambda/https endpoint.

Jhon Jairo.

lucapalano commented 3 years ago

Same issue for me. Any news about this?

sattpat commented 3 years ago

Apologies for not updating the issue. Last time around I wasnt able to simulate the issue. @lucapalano and @jhonj98, is the locale you are using for testing, consistent with language used in your skill code base? In case of @jhonj98 , the response returned by your LOCAL skill code is in MX as well? @lucapalano and @jhonj98 if you can supply me the latest skill id that you are using when encountering this issue, that would be great.

lucapalano commented 3 years ago

Hi everyone,

is the locale you are using for testing, consistent with language used in your skill code base?

I don't know what NodeJS version was used by @jhonj98 . I'm using NodeJS 14.x with VSCode 1.53.2 on Mac OS X. I also tested it with embedded Skill Simulation in VSCode and from ask cli.

However, I found a solution to my issue. In my case, the timeout was due to the wrong handler registration:

let skill;

exports.handler = async function (event, context) {
  console.log(`REQUEST++++${JSON.stringify(event)}`);
  if (!skill) {
    skill = Alexa.SkillBuilders.custom()
      .addRequestHandlers(
        LaunchRequestHandler,
        HelloWorldIntentHandler,
        HelpIntentHandler,
        CancelAndStopIntentHandler,
        SessionEndedRequestHandler,
      )
      .addErrorHandlers(ErrorHandler)
      .create();
  }

  const response = await skill.invoke(event, context);
  console.log(`RESPONSE++++${JSON.stringify(response)}`);

  return response;
};

It was copied from this amazon guide. It worked when deployed remotely in the lambda but doesn't work when testing locally. Here is the working code:

exports.handler = Alexa.SkillBuilders.custom()
      .addRequestHandlers(
        LaunchRequestHandler,
        HelloWorldIntentHandler,
        HelpIntentHandler,
        CancelAndStopIntentHandler,
        SessionEndedRequestHandler,
      )
      .addErrorHandlers(ErrorHandler)
      .lambda();

In this case, no timeout has been generated when tested locally.

I don't know if this will also fix the @jhonj98 issue.

I hope this will help other people.

Best, Luca

sattpat commented 3 years ago

Marking the issue for closure. Please reopen if the issue hasnt been resolved.

arunsingh28 commented 3 years ago

.

FelixSelter commented 2 years ago

Same issue for me

doiron commented 2 years ago

Hi FelixSelter, could you post the code where you build the skill, ie Alexa.SkillBuilders and comment on your skillId at the same time you attempt so I can know when to search for in the logs.

thanks

techandsoftware commented 2 years ago

I've got the same issue. Debugging with --region EU was unreliable, the debug console would hang then eventually get an exception. Today, local debugging doesn't even start with --region EU, as I get a websocket 500 error. I switched to --region NA and downloaded the same skill with an NA account, and this debugs reliably.