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

Twitter.post crashes silently #156

Open
creativecreatorormaybenot opened this issue Mar 17, 2021 · 0 comments
Open

Twitter.post crashes silently #156

creativecreatorormaybenot opened this issue Mar 17, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@creativecreatorormaybenot

Use case

I use Twitter.post in order to post status updates, i.e. all my calls are as simple as:

const twitter = new Twitter(config)

await twitter.post('statuses/update', {
  status: tweet,
})

Problem

Whenever Twitter rejects my tweet because I am:

  • Exceeding 280 characters
  • Posting the same tweet twice in a row
  • Trying to post multiple tweets at once
  • etc.

twitter.post completely crashes my function. I get no errors. Instead, my logs look like this:

undefined
Function execution took 16076 ms, finished with status: 'error'

The undefined is only printed when twitter.post crashes.

Try-catch

The README says that I should be able to catch errors:

client
  .get("account/verify_credentials")
  .then(results => {
    console.log("results", results);
  })
  .catch(console.error);

However, this does not work for me. The catch block is simply never executed and I get the same undefined and function stopped behavior.

Reproduction

I know for a fact that this is exactly what happens. Both because I debugged this a lot and also because I have my Google Cloud Function set up with a CRON job - it just failed for 17 hours straight (see creativecreatorormaybenot/github-tracker#54).

You can view my code here (open source implementation). I have the twitter.post call in three other places and whenever it is called before the end of the function, e.g. here, the function will crash immediately and not save any data (which is how I can confirm that this is the actual behavior). Once I remove the twitter.post calls, everything works again. However, using try { await twitter.post(..) } catch {} does not help and neither does .catch.

Environment

I am running in a Google Cloud Functions environment using Node 12 and Typescript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants