diff --git a/apps/site/public/robots.txt b/apps/site/public/robots.txt new file mode 100644 index 00000000..6a9dfd76 --- /dev/null +++ b/apps/site/public/robots.txt @@ -0,0 +1,10 @@ +# Tracks, albums and single listens multiply into far more pages than are worth +# crawling, and every one is a fresh database query. Artists, profiles and the +# home page stay open. +User-agent: * +Disallow: /track/ +Disallow: /album/ +Disallow: /listen/ +Disallow: /oauth/ +Disallow: /_serverFn/ +Disallow: /*? diff --git a/apps/site/src/lib/api.ts b/apps/site/src/lib/api.ts index bb8ad46c..dfb973fe 100644 --- a/apps/site/src/lib/api.ts +++ b/apps/site/src/lib/api.ts @@ -199,16 +199,25 @@ export const getListen = createServerFn({ method: "GET" }) const doc = await resolveActor(data.actor); if (!doc) throw notFound(); - const records = await Promise.all( + // Slingshot answers some PDSes' missing records with a 500, so one + // collection failing mustn't hide the play from the other. + const results = await Promise.allSettled( PLAY_COLLECTIONS.map((collection) => cached(`rec:${doc.did}/${collection}/${data.rkey}`, 15, () => getRecord(doc.did, collection, data.rkey), ), ), ); + const records = results.map((result) => + result.status === "fulfilled" ? result.value : undefined, + ); const index = records.findIndex((record) => record !== undefined); const record = records[index]; - if (!record) throw notFound(); + if (!record) { + const failed = results.find((result) => result.status === "rejected"); + if (failed) throw failed.reason; + throw notFound(); + } const uri = `at://${doc.did}/${PLAY_COLLECTIONS[index]}/${data.rkey}`; const play = playOf(uri, doc.did, record, tidTime(data.rkey));