Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase Promise Failure #395

Open
davewoodward opened this issue Oct 28, 2019 · 2 comments
Open

Firebase Promise Failure #395

davewoodward opened this issue Oct 28, 2019 · 2 comments
Labels

Comments

@davewoodward
Copy link

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);
  // });
});
@dblock
Copy link
Collaborator

dblock commented Oct 28, 2019

The returned promise looks suspicious. Write a unit test for this, does it complete in the right order? I mean does the promise resolve after the say is called?

@dblock dblock added the bug? label Oct 28, 2019
@davewoodward
Copy link
Author

A quick follow-up on this. I wrote a unit test for this and have also tested it locally using the alexa-app-server and it works fine. Unfortunately, it stops working whenever I deploy it to AWS. I haven't completely gotten to the bottom of it yet but I think that your comment regarding the promise looking suspicious was on point. I say this because native promises are working fine for me; both locally and deployed. Because of the timeline I am working under I implemented a work-around by switching to the Firebase rest interface and avoiding the firebase admin SDK altogether.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants