TypeError: Cannot read property 'stack' of undefined for Action on google node module
I am using Firebase cloud functions as webhook for my action-on-google dialogflow fulfilment.
I am showing only part of My index.js file as below
process.env.DEBUG = 'actions-on-google:*';
var requestcall = require('request');
var date = require('date-and-time');
var promise = require('promise');
var AmazonDateParser = require('amazon-date-parser');
var moment = require('moment-timezone');
var accountnum;
var accessToken;
var timePeriod;
var acctnums =[];
const OUT_CONTEXT = 'output_context';
const ACCOUNT_ARG = 'info';
const ACCOUNT_NUM = 'myAccountNum';
const AccountNums = 'AccountNums';
const CURRENCY_SYMBOL = 'CurrencySymbol';
const TIME_ZONE = 'TimeZone';
const STATS_ARG = 'nextStatsData';
const {dialogflow} = require('actions-on-google');
const functions = require('firebase-functions');
const {
SimpleResponse,
BasicCard,
Image,
Suggestions,
Button
} = require('actions-on-google');
const app = dialogflow(
{debug: true,clientId: 'xxxxxxxxxxx.apps.googleusercontent.com'});
app.intent('Default Welcome Intent', (conv) => {
console.log('Request headers: ' + JSON.stringify(conv.headers));
console.log('Request body: ' + JSON.stringify(conv.body));
accessToken =conv.body.originalDetectIntentRequest.payload.user.accessToken;
console.log('accessToken: ' + accessToken);
if (accessToken !== null) {
return getaccountDetails(conv).then((entity)=>{
return getMessageFromAccount(entity,conv);
});
}
else{
return conv.close(new SignIn('To get your account details'));
}
});
exports.stats = functions.https.onRequest(app);
My package.json file is as below
"description": "Cloud Functions for Firebase",
"scripts": {
"serve": "firebase serve --only functions",
"shell": "firebase experimental:functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"dependencies": {
"actions-on-google": "^2.12.0",
"amazon-date-parser": "^0.1.5",
"date-and-time": "^0.6.3",
"dialogflow": "^0.6.0",
"firebase-admin": "^6.5.1",
"firebase-functions": "^3.9.0",
"moment-timezone": "^0.5.31",
"node-pre-gyp": "^0.15.0",
"promise": "^8.1.0",
"request": "^2.88.2"
},
"engines": {
"node": "10"
},
"devDependencies": {
"firebase-functions-test": "^0.2.1"
},
"private": true,
"version": "1.0.0",
"main": "index.js",
"author": "",
"license": "ISC"
}
I am getting the following error while testing my actions-on-google
at standard.then.catch (/workspace/node_modules/actions-on-google/dist/framework/express.js:37:32)
at process._tickCallback (internal/process/next_tick.js:68:7)
Error is not in my index.js. The error is in actions-on-google npm modules library at express.js.
I deleted my node modules and installed again and rebuild the code. still same error coming.
Please help me in solving this issue.
Can you provide the full stacktrace? The snippet provided doesn't include an error message. When does this error happen? Before deploying to Firebase?
Hi @Fleker the error occurs for my first call only. When i start Talk to my action..then account linking happening successfully and after that i am getting error saying that your action is not responding. Then i went to firebase to check the logs and i got this error log. That is the full stack trace from firebase logs
TypeError: Cannot read property 'stack' of undefined
at standard.then.catch (/workspace/node_modules/actions-on-google/dist/framework/express.js:37:32)
at process._tickCallback (internal/process/next_tick.js:68:7)
Previously my action was working fine,recently i changed my firebase function node js version to 10 and again i updated all my node modules to the latest which you can see in pacakge.json.
Its strange for me to, i don't understand where the error is coming, but as per the log it is happening inside actions-on-google node module at express.js.
This line is throwing an error in your code, but haven't determined why.
So what is the solution for this @Fleker. Please guide me as my action is deployed and people will be using it.
I'm investigating this at the moment
I am unable to reproduce the error you're facing even with replicating your Default Welcome Intent. Are there any other logs like the request header/body when this happens, which may be able to help diagnose why this may happen?
Yes @Fleker i have both request header and body. Please check below for both
Request Header
{"host":"us-central1-click-and-pledge-air.cloudfunctions.net","user-agent":"Google-Dialogflow","transfer-encoding":"chunked","accept":"*/*","accept-encoding":"gzip,deflate,br","content-type":"application/json","forwarded":"for=\"66.249.84.230\";proto=https","function-execution-id":"q7lw68klo13t","x-appengine-country":"ZZ","x-appengine-default-version-hostname":"l70a2a9e459fc4366-tp.appspot.com","x-appengine-https":"on","x-appengine-request-log-id":"5f3d212500ff0d291d7ae3441e0001737e6c373061326139653435396663343336362d7470000134323231326565613265383762663265346233383062316438303765306431643a313834000100","x-appengine-timeout-ms":"599999","x-appengine-user-ip":"66.249.84.230","x-cloud-trace-context":"436f4dc10cf95d7835ba35293bee0cf4/771850088506812945;o=1","x-forwarded-for":"66.249.84.230","x-forwarded-proto":"https","connection":"close"}
Request Body
{"responseId":"2e726734-6621-4799-a2e5-df354e83c05a-d794dba9","queryResult":{"queryText":"GOOGLE_ASSISTANT_WELCOME","action":"input.welcome","parameters":{},"allRequiredParamsPresent":true,"outputContexts":[{"name":"projects/click-and-pledge-air/agent/sessions/ABwppHF8prJHi40mkHEvjyMO0UnXA1kZfAdL8k8YFYeHJYHk-vr-hNlYsyltJszRb5vM6GmT7_sW9UTIfJqkPxGEaBA/contexts/actions_capability_media_response_audio"},{"name":"projects/click-and-pledge-air/agent/sessions/ABwppHF8prJHi40mkHEvjyMO0UnXA1kZfAdL8k8YFYeHJYHk-vr-hNlYsyltJszRb5vM6GmT7_sW9UTIfJqkPxGEaBA/contexts/actions_capability_audio_output"},{"name":"projects/click-and-pledge-air/agent/sessions/ABwppHF8prJHi40mkHEvjyMO0UnXA1kZfAdL8k8YFYeHJYHk-vr-hNlYsyltJszRb5vM6GmT7_sW9UTIfJqkPxGEaBA/contexts/actions_capability_screen_output"},{"name":"projects/click-and-pledge-air/agent/sessions/ABwppHF8prJHi40mkHEvjyMO0UnXA1kZfAdL8k8YFYeHJYHk-vr-hNlYsyltJszRb5vM6GmT7_sW9UTIfJqkPxGEaBA/contexts/actions_capability_account_linking"},{"name":"projects/click-and-pledge-air/agent/sessions/ABwppHF8prJHi40mkHEvjyMO0UnXA1kZfAdL8k8YFYeHJYHk-vr-hNlYsyltJszRb5vM6GmT7_sW9UTIfJqkPxGEaBA/contexts/google_assistant_input_type_voice"},{"name":"projects/click-and-pledge-air/agent/sessions/ABwppHF8prJHi40mkHEvjyMO0UnXA1kZfAdL8k8YFYeHJYHk-vr-hNlYsyltJszRb5vM6GmT7_sW9UTIfJqkPxGEaBA/contexts/google_assistant_welcome"},{"name":"projects/click-and-pledge-air/agent/sessions/ABwppHF8prJHi40mkHEvjyMO0UnXA1kZfAdL8k8YFYeHJYHk-vr-hNlYsyltJszRb5vM6GmT7_sW9UTIfJqkPxGEaBA/contexts/__system_counters__","parameters":{"no-input":0,"no-match":0}}],"intent":{"name":"projects/click-and-pledge-air/agent/intents/5e1ffcfe-48d1-4bf0-84b4-4b7506a0666c","displayName":"Default Welcome Intent"},"intentDetectionConfidence":1,"languageCode":"en"},"originalDetectIntentRequest":{"source":"google","version":"2","payload":{"user":{"accessToken":"eyJhbGciOiJSUzI1NiIsImtpZCI6IjYxMTk2Q0YzRTY5NzQ0QUE4QUUwMzgxNkE5NzRDNUZFMzg1NjBFQTkiLCJ0eXAiOiJKV1QiLCJ4NXQiOiJZUmxzOC1hWFJLcUs0RGdXcVhURl9qaFdEcWsifQ.eyJuYmYiOjE1OTc4Mzk0NDIsImV4cCI6MTU5Nzg0MzA0MiwiaXNzIjoiaHR0cHM6Ly9hYWFzLmNsb3VkLmNsaWNrYW5kcGxlZGdlLmNvbS9pZHNlcnZlci8iLCJhdWQiOiJodHRwczovL2FhYXMuY2xvdWQuY2xpY2thbmRwbGVkZ2UuY29tL2lkc2VydmVyL3Jlc291cmNlcyIsImNsaWVudF9pZCI6Ikdvb2dsZUFzc2lzdGFudCIsInN1YiI6InBhbGxlLnNpdmFzYW5rYXJyZWRkeUBjbGlja2FuZHBsZWRnZS5jb20iLCJhdXRoX3RpbWUiOjE1OTc4Mzk0MzgsImlkcCI6ImxvY2FsIiwic2NvcGUiOlsib3BlbmlkIiwicHJvZmlsZSIsIm9mZmxpbmVfYWNjZXNzIl0sImFtciI6WyJwd2QiXX0.d_sCxPmfGIp-XBkCiepsXaSJL5SCVOok2sHeFETzGPgkQHlaVb2pik3owJTcEBSUYSeTirYfvXrC8cL58duGI39GAz4SbpiyRaym5k2IhJJ6hkOzS2Xmss6PB6AdSEd6MZ8R-HBBrRkSfeaynnJlHVtY41dpb6kt8V-dNLZ2-jj6qshrOiWkVJ7s-jkIebyQAtXl70jEuCd1GU_vjxWU2r2rVgFFOR0uwSU29nzI4T_H1uPEOv6YgcTVeMrol7hAhun8aSYGCwNbba5pKPn4lYlz_PWUdidQFvudkPiO8BSKQD24Z1oEakb4cgjwO9OwTSjVTeFzNgubkuy5fE-m4A","locale":"en-US","userVerificationStatus":"VERIFIED"},"conversation":{"conversationId":"ABwppHF8prJHi40mkHEvjyMO0UnXA1kZfAdL8k8YFYeHJYHk-vr-hNlYsyltJszRb5vM6GmT7_sW9UTIfJqkPxGEaBA","type":"NEW"},"inputs":[{"intent":"actions.intent.MAIN","rawInputs":[{"inputType":"VOICE","query":"Talk to Click & Pledge"}]}],"surface":{"capabilities":[{"name":"actions.capability.MEDIA_RESPONSE_AUDIO"},{"name":"actions.capability.AUDIO_OUTPUT"},{"name":"actions.capability.SCREEN_OUTPUT"},{"name":"actions.capability.ACCOUNT_LINKING"}]},"isInSandbox":true,"availableSurfaces":[{"capabilities":[{"name":"actions.capability.AUDIO_OUTPUT"},{"name":"actions.capability.SCREEN_OUTPUT"},{"name":"actions.capability.WEB_BROWSER"}]}],"requestType":"SIMULATOR"}},"session":"projects/click-and-pledge-air/agent/sessions/ABwppHF8prJHi40mkHEvjyMO0UnXA1kZfAdL8k8YFYeHJYHk-vr-hNlYsyltJszRb5vM6GmT7_sW9UTIfJqkPxGEaBA"}
Hope this will help you solve the issue.
I am not encountering this error when trying this on my own example project.
@Fleker can you drop your mail, i will send you my whole code zip folder so that you can check that. if you have problem sharing your mail publicly please reply to my mail i will forward you.
my mail id : [email protected].