react-static-tweets icon indicating copy to clipboard operation
react-static-tweets copied to clipboard

`fetchTweetAst` returns null

Open kush-mish opened this issue 2 years ago • 5 comments

fetchTweetAst returns null intermittently.

kush-mish avatar Apr 26 '22 15:04 kush-mish

There's a bug in vercel's implementation of fetch which static-tweets is leveraging on subsequent calls vercel's fetch is returning null.

If you add this postinstall script to your package.json, should temp fix the issue and use default implementation of fetch.

"postinstall": "perl -pi -e 's/var fetch.*//g' node_modules/static-tweets/build/index.js"

sanjay-io avatar May 14 '22 20:05 sanjay-io

@sanjay-io Is there an open issue on vercel/fetch for this? We can take a look.

leerob avatar Jun 05 '22 19:06 leerob

hey @leerob, I didn't find an open issue that was indicative of this problem, my mistake for not creating one. I created one over here with much more information:

https://github.com/vercel/fetch/issues/69

sanjay-io avatar Jun 05 '22 20:06 sanjay-io

After some investigation, the same behavior occurs using node-fetch, got, and even the underlying node:https module directly.

The first GET is always successful, and subsequent GET requests 404. If you override the https agent to disable TLS session caching, then everything works fine. This is probably symptomatic of a weird TLS bug on Twitter's side, or it may be intentional on Twitter's behalf since the approach this library uses is kind of piggy-backing on Twitter's syndication API in a way that it wasn't intended to be used.

In any case, the fix will be to disable TLS caching when making calls to Twitter's syndication API. I'll include this fix in an update shortly.

transitive-bullshit avatar Jun 10 '22 05:06 transitive-bullshit

+1 getting the same problem. As a matter of fact for me const ast = await fetchTweetAst(tweetId); returns null all the time (not only intermittently)

jellohouse avatar Sep 15 '22 01:09 jellohouse

This should now be fixed in v1.0.0.

transitive-bullshit avatar Oct 28 '22 03:10 transitive-bullshit