Closed iznaut closed 4 days ago
I am seeing the same thing:
> twittertobluesky@0.3.1 start_log
> npx tsc && node app.js > import.log
node:internal/process/promises:394
triggerUncaughtException(err, true /* fromPromise */);
^
AssertionError [ERR_ASSERTION]: protocol mismatch
at Object.request (/home/jay/Bluesky/node_modules/follow-redirects/index.js:530:14)
at Object.get (/home/jay/Bluesky/node_modules/follow-redirects/index.js:537:44)
at /home/jay/Bluesky/app.js:51:34
at new Promise (<anonymous>)
at resolveShorURL (/home/jay/Bluesky/app.js:50:12)
at cleanTweetText (/home/jay/Bluesky/app.js:69:34)
at main (/home/jay/Bluesky/app.js:233:34)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: 'http:',
expected: 'https:',
operator: '=='
}
Node.js v22.10.0
SIMULATE is OFF
Parse tweet id '652973377452306432'
Created at 2015-10-10T22:25:59.000Z
Full text 'Made a Twitter! Let's hope I actually remember to use it this time. #myfirstTweet'
Bluesky post create, URL: https://bsky.app/profile/englishmobster.bsky.social/post/3l72xqdt3bm2x
Parse tweet id '652974931467091968'
Created at 2015-10-10T22:32:10.000Z
Full text 'A bunch of screenshots from "Tusks and Tigerskins", the game I'm working on: http://t.co/BadSkgikFD #screenshotsaturday'
I think the issue is the shortened link - it's http://, not https://. Doing a find and replace http -> https in data/tweets.js helped a bit, but I still failed out a little later with a different error:
> twittertobluesky@0.3.1 start_log
> npx tsc && node app.js > import.log
Error parsing url https://t.co/cEVbnUq94r
Error parsing url https://t.co/37jqou8xnR
Error parsing url https://t.co/mgyocrvVmc
Error parsing url https://t.co/ffqO50oVYO
Error parsing url https://t.co/hsy0yvex34
Error parsing url https://t.co/37jqou8xnR
/home/jay/Bluesky/node_modules/@atproto/xrpc/dist/xrpc-client.js:75
throw new types_1.XRPCError(resCode, error, message, resHeaders);
^
XRPCError: This file is too large. It is 1.31MB but the maximum size is 976.56KB.
at AtpAgent.call (/home/jay/Bluesky/node_modules/@atproto/xrpc/dist/xrpc-client.js:75:23)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async PostRecord.create (/home/jay/Bluesky/node_modules/@atproto/api/dist/client/index.js:1282:21)
at async main (/home/jay/Bluesky/app.js:264:36) {
error: 'BlobTooLarge',
headers: {
'access-control-allow-origin': '*',
'cache-control': 'private',
'content-length': '107',
'content-type': 'application/json; charset=utf-8',
date: 'Tue, 22 Oct 2024 02:28:14 GMT',
etag: 'W/"6b-XCfHuE8hl1kyJbs0m3Osfof07Pg"',
'keep-alive': 'timeout=90',
'ratelimit-limit': '5000',
'ratelimit-policy': '5000;w=3600',
'ratelimit-remaining': '4972',
'ratelimit-reset': '1729567277',
'strict-transport-security': 'max-age=63072000',
vary: 'Authorization, Accept-Encoding',
'x-powered-by': 'Express'
},
success: false,
status: 400
}
@Jay2645 they should be two different problems, for the http url resolution problem I made a branch with a possible fix https://github.com/marcomaroni-github/twitter-to-bluesky/tree/9-assertion-protocol-mismatch, @Jay2645 @iznaut try it and tell me if it solves the "protocol mismatch" problem
@marcomaroni-github I was going to submit a PR, but I see that you're already working on it.
I resolved this in the resolveShorURL
function by checking if the URL was http / s and then using the appropriate url:
I first imported both http
and https
at the top:
import { https, http } from 'follow-redirects';
async function resolveShorURL(url: string): Promise<string> {
const isHttp = url.startsWith("http://");
return new Promise<string>((resolve, reject) => {
if (isHttp) {
http.get(url, response => {
resolve(response.responseUrl);
}).on('error', err => {
console.warn(`Error parsing url ${url}`);
resolve(url);
});
} else {
https.get(url, response => {
resolve(response.responseUrl);
}).on('error', err => {
console.warn(`Error parsing url ${url}`);
resolve(url);
});
}
});
}
@paceaux yes, your solution is very similar to mine, you can check it into the branch https://github.com/marcomaroni-github/twitter-to-bluesky/tree/9-assertion-protocol-mismatch
@marcomaroni-github Nice.
Not that my opinion matters but... ¿approved?
branch worked for a while, but died on a different issue (see #11 )
great work though!
Based on what I can tell from the log, it looks like it's failing on this tweet since it's the last one (and doesn't get posted to Bluesky: