From 8ad5a8f8e69842d801fde2eaea22e2c77af82804 Mon Sep 17 00:00:00 2001 From: WebStreamr <210764791+webstreamr@users.noreply.github.com> Date: Sun, 20 Jul 2025 11:37:01 +0000 Subject: [PATCH] chore: add explicit info that we can't fix 5xx errors --- src/utils/StreamResolver.test.ts | 11 ++++++++++ src/utils/StreamResolver.ts | 5 +++++ .../__snapshots__/StreamResolver.test.ts.snap | 22 +++++++++++++++++-- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/utils/StreamResolver.test.ts b/src/utils/StreamResolver.test.ts index b98d81a..e2d6be1 100644 --- a/src/utils/StreamResolver.test.ts +++ b/src/utils/StreamResolver.test.ts @@ -207,6 +207,17 @@ describe('resolve', () => { countryCodes: [CountryCode.de], }, }, + { + url: new URL('https://example5.com'), + format: Format.unknown, + isExternal: true, + error: new HttpError(418, 'I\'m a tea pot', { 'x-foo': 'bar' }), + label: 'hoster.com', + sourceId: '', + meta: { + countryCodes: [CountryCode.de], + }, + }, ]; } diff --git a/src/utils/StreamResolver.ts b/src/utils/StreamResolver.ts index 7764fdd..2267c4d 100644 --- a/src/utils/StreamResolver.ts +++ b/src/utils/StreamResolver.ts @@ -210,6 +210,11 @@ export class StreamResolver { if (error instanceof HttpError) { this.logger.error(`${source}: HTTP status ${error.status} (${error.statusText}), headers: ${JSON.stringify(error.headers)}, stack: ${error.stack}.`, ctx); + + if (error.status >= 500) { + return `❌ Remote server has issues. We can't fix this, please try later again.`; + } + return `❌ Request failed with status ${error.status} (${error.statusText}). Request-id: ${ctx.id}.`; } diff --git a/src/utils/__snapshots__/StreamResolver.test.ts.snap b/src/utils/__snapshots__/StreamResolver.test.ts.snap index 6d04cf1..5e40af2 100644 --- a/src/utils/__snapshots__/StreamResolver.test.ts.snap +++ b/src/utils/__snapshots__/StreamResolver.test.ts.snap @@ -100,7 +100,16 @@ exports[`resolve adds error info 1`] = ` "externalUrl": "http://localhost/", "name": "WebStreamr 🇩🇪", "title": "🔗 hoster.com -❌ Request failed with status 500 (Internal Server Error). Request-id: test.", +❌ Remote server has issues. We can't fix this, please try later again.", + }, + { + "behaviorHints": { + "notWebReady": true, + }, + "externalUrl": "http://localhost/", + "name": "WebStreamr 🇩🇪", + "title": "🔗 hoster.com +❌ Request failed with status 418 (I'm a tea pot). Request-id: test.", }, ], } @@ -206,7 +215,16 @@ exports[`resolve adds error info 2`] = ` "externalUrl": "https://example4.com/", "name": "WebStreamr 🇩🇪 ⚠️ external", "title": "🔗 hoster.com -❌ Request failed with status 500 (Internal Server Error). Request-id: test.", +❌ Remote server has issues. We can't fix this, please try later again.", + }, + { + "behaviorHints": { + "notWebReady": true, + }, + "externalUrl": "https://example5.com/", + "name": "WebStreamr 🇩🇪 ⚠️ external", + "title": "🔗 hoster.com +❌ Request failed with status 418 (I'm a tea pot). Request-id: test.", }, ], }