Error: Not Found at Gaxios.<anonymous> when trying to get history list from Gmail - node.js

I'm trying to process a push notification from Gmail by follow the instruction from this link. I modified some code to read from historyId instead of most recent message like recommended in the guide.
It's normally work find but sometime the problem occurred after received a push notification. The script failed to call Gmail API:
gmail-watch-fs yv1ke4cc0tk8 Error: Not Found
at Gaxios.<anonymous> (/srv/node_modules/gaxios/build/src/gaxios.js:73:27)
at Generator.next (<anonymous>)
at fulfilled (/srv/node_modules/gaxios/build/src/gaxios.js:16:58)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:229:7)
Here is the line that cause error:
const historyRes = await gmail.users.history.list({
userId: "me",
startHistoryId: historyId,
historyTypes: ["messageAdded"],
})
I found a Japanese site suggest to enable IAM API but it's already enabled in my case. Can anyone help me with this?

The problem is because I try to listen to many subscribed email address by only one Cloud Function instance. It is solved by generate more Cloud Function (one per each subscribed email).

Related

WebHook call failed. Error: DEADLINE_EXCEEDED, State: URL_TIMEOUT, Reason: TIMEOUT_WEB calling from node

I am not sure what mistake I am doing. I have create a ChatBot in google dialog flow and did setup of WebHook in my local. Once I am hitting from dialogbox then reuqest is landing to code and processed successfully but in Dialogflow response I am getting failure due to some TimOut exception, there a way to fix this . I am facing WebHook call failed. Error: DEADLINE_EXCEEDED, State: URL_TIMEOUT, Reason: TIMEOUT_WEB calling from node.
Below is the index.json snippet :
Below is the console log
At the end of the function you need to resolve the promise.
return Promise.resolve();
Additionally, you're probably already handling errors but in a Firebase Function, if you need to throw an error, you can do that simply this way:
throw new functions.https.HttpsError(
'internal',
'Woops, that should not happen.',
);

how to debug error from stripe API call? need a node.js stacktrace across event emitter?

I have a node webapp that makes various API calls to Stripe using the stripe npm package. Sometimes I get errors like the one below. Notice that the stacktrace is truncated so that I cannot see which stripe API call causes the error and I also cannot see where in my app this API call is made.
Is there anything I can do to get better error stacktraces?
Error: Missing required param: customer.
at Function.generate (/home/molsson/dv/foobar/node_modules/stripe/lib/Error.js:39:16)
at IncomingMessage.<anonymous> (/home/molsson/dv/foobar/node_modules/stripe/lib/StripeResource.js:175:33)
at Object.onceWrapper (events.js:299:28)
at IncomingMessage.emit (events.js:215:7)
at IncomingMessage.EventEmitter.emit (domain.js:476:20)
at endReadableNT (_stream_readable.js:1183:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Note: the error itself is just an example. I have already fixed it. I just want to get better stacktraces or a better method of debugging these types of errors quickly.
I'm pretty sure my node version has async stacks by default:
$ node --version
v12.12.0
$ node -p process.versions.v8
7.7.299.13-node.12
I tried running with NODE_OPTIONS='--trace-warnings --stack-trace-limit=9999' but it didn't help.
Does it exists some kind of "async stacktraces across event emitters" debugging thing?
I found a good answer to this question myself. The stripe library fires and event before making a new API request, so you can print a stacktrace from there:
stripe.on('request', request => {
const currentStack = (new Error()).stack.replace(/^Error/, '')
console.log(`Making Stripe HTTP request to ${request.path}, callsite: ${currentStack}`)
})
I added a STRIPE_API_TRACING option to my app that I can turn on if I experience errors without stacks. With the tracing on I can just scroll a bit up in the log and see what API calls was dispatched just before the error happened.

Twitter API issue (code: 349, message: 'You cannot send messages to this user.') in node.js

I am sending message by using direct_messages/events/new method in Node.js by using API,
But i am getting the errors like { code: 349, message: 'You cannot send messages to this user.' }
please help me to solve this issue.
Thanks
If the user is not following you or has blocked you, then you will not be able to send messages to the user.
You can also send messages to a user that is not following you but has DM'd you (e.g. if your id accepts DMs without requiring mutual following). However, if the user is not following you/has blocked you (as mentioned by Andy Piper) or has not DM'd you, you'll receive the "code: 349, message: 'You cannot send messages to this user.'" error. Tested via postman using the direct message api (https://api.twitter.com/1.1/direct_messages/events/new.json).

#chatbase Error with not handled function in node mode

I am trying to connect my bot with chatbase.
For that I have generated the API key and connected it with after that I have set my intent with function sendChatbaseHandledMessage and sendChatbaseNotHandledMessage.
While I use sendChatbaseNotHandledMessage it gives this error:
The message cannot be set as not_handled and not be of type user.
at MessageStateWrapper.exportCreatePayload (/home/runner/node_modules/#google/chatbase/lib/MessageSink.js:426:14)
at Promise (/home/runner/node_modules/#google/chatbase/lib/MessageStateWrapper.js:145:29)
at new Promise (<anonymous>)
at MessageStateWrapper.send (/home/runner/node_modules/#google/chatbase/lib/MessageStateWrapper.js:141:12)
at sendChatbaseNotHandledMessage (evalmachine.<anonymous>:36:143)
at evalmachine.<anonymous>:39:3
at Script.runInContext (vm.js:74:29)
at Object.runInContext (vm.js:182:6)
at evaluate (/run_dir/repl.js:133:14)
at ReadStream.<anonymous> (/run_dir/repl.js:116:5)
As I can understand, the issue is with the chatbase node_modules with some library.
Can I get some solution for it?
Reposting the response from our engineer to the internal thread for reference.
It looks like the error is:
message cannot be set as not_handled and not be of type user
Not handled messages in the chatbase API can only by of type user so one would need to say:
var msg = chatbase.newMessage('my-api-key', 'my-user-id')
msg.setAsTypeUser().setAsNotHandled().send()...
In the chatbase API one cannot set agent messages as not handled, so the following is not allowed:
msg.setAsTypeAgent().setAsNotHandled()

Padding is invalid and cannot be removed while sending push event to my application

We are using Docusign Connect to leverage the push functionality. This feature is great and we are no more worried of reaching REST call limits.
But while checking connect logs on DocuSign console- We found failure entry which is failing because of below error:
9/16/2013 6:50:23 AM Connect send to: https://myURL.com/EventListener
9/16/2013 6:50:23 AM Envelope Data (documents were included):
9/16/2013 6:50:23 AM Error: Exception in EnvelopeIntegration.RunIntegration: <EnvelopeID> :: https://myURL.com/EventListener :: Error - Exception decrypting. Padding is invalid and cannot be removed. Original Exception: Padding is invalid and cannot be removed.
Looks like this is some internal exception at Docusign. Can someone help us to resolve this issue?
This is indeed a bug on DocuSign's side. It's newly introduced which means it most likely came from the latest release. Will post an update here once resolved, thanks for your patience.
DocuSign Team

Resources