marcomaroni-github / twitter-to-bluesky

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

"follow-redirects" package internal hangup while processing redirect #40

Open clemensv opened 4 days ago

clemensv commented 4 days ago

I propose the following code with a timeout to replace line https://github.com/marcomaroni-github/twitter-to-bluesky/blob/main/app.ts#L95

I have run into a condition where the "follow-redirects" package appears to deadlock and hangs forever while processing a redirect. The thread gets eaten by this line https://github.com/follow-redirects/follow-redirects/blob/main/index.js#L659. The external timeout gets around this. I am not submitted this as a PR since there seems to be an underlying issue that I have no time to chase down. Use this if that's enough for you; it's enough for me.

FWIW, the library balked on http://tinyurl.com/3pe4y42

        const newUrl = await Promise.race([
            new Promise<string>((resolve, reject) => {
                setTimeout(() => reject(new Error('Timeout')), 5000);
            }),
            urlMappings.find(({url}) => urls[index] == url )?.expanded_url ?? resolveShorURL(urls[index])
        ]).catch(err => {
            console.warn(`Error resolving URL: ${urls[index]}  ${err.message}`);
            return urls[index];
        });
clemensv commented 4 days ago

Filed https://github.com/follow-redirects/follow-redirects/issues/273