Browse Source
fix: don't fail whole request if one of providers fails, but log it
Signed-off-by: Anatoly Popov <me@aensidhe.ru>
pull/4715/head
Anatoly Popov
2 months ago
Failed to extract signature
3 changed files with
15 additions and
4 deletions
-
apps/api/src/app/endpoints/data-providers/ghostfolio/ghostfolio.service.ts
-
apps/api/src/services/data-provider/data-provider.service.ts
-
apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts
|
|
@ -294,9 +294,14 @@ export class GhostfolioService { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
const searchResults = await Promise.all(promises); |
|
|
|
const searchResults = await Promise.allSettled(promises); |
|
|
|
|
|
|
|
for (const { items } of searchResults) { |
|
|
|
for (const result of searchResults) { |
|
|
|
if (result.status === 'rejected') { |
|
|
|
Logger.warn(result.reason, 'GhostfolioService'); |
|
|
|
continue; |
|
|
|
} |
|
|
|
const { items } = result.value; |
|
|
|
if (items?.length > 0) { |
|
|
|
lookupItems = lookupItems.concat(items); |
|
|
|
} |
|
|
|
|
|
@ -652,9 +652,14 @@ export class DataProviderService { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
const searchResults = await Promise.all(promises); |
|
|
|
const searchResults = await Promise.allSettled(promises); |
|
|
|
|
|
|
|
for (const { items } of searchResults) { |
|
|
|
for (const result of searchResults) { |
|
|
|
if (result.status === 'rejected') { |
|
|
|
Logger.warn(result.reason, 'DataProviderService'); |
|
|
|
continue; |
|
|
|
} |
|
|
|
const { items } = result.value; |
|
|
|
if (items?.length > 0) { |
|
|
|
lookupItems = lookupItems.concat(items); |
|
|
|
} |
|
|
|
|
|
@ -331,6 +331,7 @@ export class YahooFinanceService implements DataProviderInterface { |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
Logger.error(error, 'YahooFinanceService'); |
|
|
|
return { items: [] }; |
|
|
|
} |
|
|
|
|
|
|
|
return { items }; |
|
|
|