diff --git a/src/utils/StreamResolver.test.ts b/src/utils/StreamResolver.test.ts index b04a5ef..8b8c3fb 100644 --- a/src/utils/StreamResolver.test.ts +++ b/src/utils/StreamResolver.test.ts @@ -73,6 +73,16 @@ describe('resolve', () => { countryCode: 'de', }, }, + { + url: new URL('https://example.com'), + isExternal: true, + error: new BlockedError('unknown', {}), + label: 'hoster.com', + sourceId: '', + meta: { + countryCode: 'de', + }, + }, { url: new URL('https://example2.com'), isExternal: true, diff --git a/src/utils/StreamResolver.ts b/src/utils/StreamResolver.ts index 9694933..3ce1039 100644 --- a/src/utils/StreamResolver.ts +++ b/src/utils/StreamResolver.ts @@ -144,7 +144,11 @@ export class StreamResolver { private readonly logErrorAndReturnNiceString = (ctx: Context, source: string, error: unknown): string => { if (error instanceof BlockedError) { - this.logger.warn(`${source}: Request was blocked. Reason: ${error.reason}, headers: ${JSON.stringify(error.headers)}`, ctx); + if (error.reason === 'cloudflare_challenge') { + this.logger.warn(`${source}: Request was blocked via Cloudflare challenge.`, ctx); + } else { + this.logger.warn(`${source}: Request was blocked, headers: ${JSON.stringify(error.headers)}.`, ctx); + } return '⚠️ Request was blocked.'; } diff --git a/src/utils/__snapshots__/StreamResolver.test.ts.snap b/src/utils/__snapshots__/StreamResolver.test.ts.snap index fd96650..9c9d2c6 100644 --- a/src/utils/__snapshots__/StreamResolver.test.ts.snap +++ b/src/utils/__snapshots__/StreamResolver.test.ts.snap @@ -9,6 +9,14 @@ exports[`resolve adds error info 1`] = ` "name": "WebStreamr N/A ⚠️ external", "title": "🌐 German 🇩🇪 🔗 hoster.com +⚠️ Request was blocked.", + }, + { + "behaviorHints": {}, + "externalUrl": "https://example.com/", + "name": "WebStreamr N/A ⚠️ external", + "title": "🌐 German 🇩🇪 +🔗 hoster.com ⚠️ Request was blocked.", }, { @@ -55,6 +63,14 @@ exports[`resolve adds error info 2`] = ` "name": "WebStreamr N/A", "title": "🌐 German 🇩🇪 🔗 hoster.com +⚠️ Request was blocked.", + "ytId": "E4WlUXrJgy4", + }, + { + "behaviorHints": {}, + "name": "WebStreamr N/A", + "title": "🌐 German 🇩🇪 +🔗 hoster.com ❌ Request failed. Request-id: id.", "ytId": "E4WlUXrJgy4", },