marcomaroni-github / twitter-to-bluesky

Import all tweets exported from X/Twitter to a Bluesky account.
Other
474 stars 35 forks source link

XRPCError: TypeError: fetch failed #21

Open grasshoppermouse opened 3 weeks ago

grasshoppermouse commented 3 weeks ago
hagen@Edwards-iMac-M3 twitter-to-bluesky % npm run start_log

> twittertobluesky@0.6.0 start_log
> npx tsc && node app.js > import.log

/Users/hagen/Documents/Misc/twitterstuff/twitter-to-bluesky/node_modules/@atproto/xrpc/dist/client.js:135
        throw new types_1.XRPCError(types_1.ResponseType.Unknown, String(e));
              ^

XRPCError: TypeError: fetch failed
    at AtpAgent.defaultFetchHandler [as fetch] (/Users/hagen/Documents/Misc/twitterstuff/twitter-to-bluesky/node_modules/@atproto/xrpc/dist/client.js:135:15)
    at async BskyAgent._fetch (/Users/hagen/Documents/Misc/twitterstuff/twitter-to-bluesky/node_modules/@atproto/api/dist/agent.js:330:19)
    at async ServiceClient.call (/Users/hagen/Documents/Misc/twitterstuff/twitter-to-bluesky/node_modules/@atproto/xrpc/dist/client.js:88:21)
    at async main (/Users/hagen/Documents/Misc/twitterstuff/twitter-to-bluesky/app.js:219:52) {
  status: 1,
  error: 'TypeError: fetch failed',
  success: false,
  headers: undefined
}

Node.js v20.16.0

Last item in the log:

Parse tweet id '1524927726657802241'
 Created at 2022-05-13T01:41:16.000Z
 Full text 'The genetic program metaphor dates back to the 60's. Since then, some have proposed that DNA/RNA is a literal computer. Here's a recent effort by @theHessam in JTB (Gallistel fans & NN critics, enjoy!)

An RNA-based theory of natural universal computation: https://t.co/HOP8JrfxGS https://t.co/3Yz3O6NUCb'
marcomaroni-github commented 3 weeks ago

The problem seems to be caused by the loading of the image in the tweet. During my tests this error occurred every now and then, but the text of the message does not help to understand the causes, and often trying to import again the error disappeared. Can you recover the image of the tweet present in the archive? Could it be corrupted or larger than 1 Mb? If it can help you locate it you can insert a "console.log" at line 237 of the app.ts file, like this:

const mediaFilename = `${process.env.ARCHIVE_FOLDER}/data/tweets_media/${tweet.id}-${media?.media_url.substring(i + 1)}`;
const imageBuffer = FS.readFileSync(mediaFilename);
console.log(mediaFilename);
grasshoppermouse commented 3 weeks ago

The image is 378 KB, and doesn't seem to be corrupted: 1524927726657802241-FSmetnaVEAAIoYE

xPaw commented 2 weeks ago

I'm getting these errors too from time to time, just restarting works. I think these are just temporary network errors that should be retried (with some backoff)