+
Skip to content

Firebase Promise Failure #395

Open
Open
@davewoodward

Description

@davewoodward

I am trying to call a Firebase function to retrieve some data from within the launch request handler and it is failing with the message "There was a problem with the requested skills response." I have reproduced the error in a simple example that I can make available but thought I would start by including the relevant code below. I am using version 4.2.3 of the alexa-app library. Looking at the log I can see that it is tracking all the way through to the res.say function call but it doesn't appear to be returning. The CloudWatch logs show "Task timed out after X seconds." Bumping up the timeout has no effect.

const Alexa = require('alexa-app');
const app = new Alexa.app('test-alexa');
const firebase = require('./firebase.js');

app.launch((req, res) => {
  console.log('launch called');

  return firebase.database().ref('config').once('value').then((snapshot) => {
    console.log('firebase returned');
    const value = snapshot.val();
    if (value) {
      console.log('value is truthy');
      res.say('This is a test. By the way, the value was truthy.').reprompt('It really was!').shouldEndSession(false).send();
    } else {
      console.log('value is not truthy');
      res.say('This is a test. By the way, the value was falsey.').reprompt('It really was!').shouldEndSession(false).send();
    }
  });

  // return Promise.resolve().then(() => {
  //   res.say('This is a test.').reprompt('It really is!').shouldEndSession(false).send();
  // });

  // return new Promise((resolve, reject) => {
  //   setTimeout(() => {
  //     resolve(res.say('This is a test!').reprompt('It really is!').shouldEndSession(false).send());
  //   }, 2000);
  // });
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载