From 0125c70ae567c2278f346eeb1fd340b5eded43f7 Mon Sep 17 00:00:00 2001 From: Chris Wilkinson Date: Fri, 17 Jan 2025 16:20:58 +0000 Subject: [PATCH] Let us know if the cache entry reloading fails Refs #2186 --- src/CachingHttpClient.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/CachingHttpClient.ts b/src/CachingHttpClient.ts index 5e294fd3f..e78b6469a 100644 --- a/src/CachingHttpClient.ts +++ b/src/CachingHttpClient.ts @@ -1,8 +1,8 @@ import { HttpClient, + HttpClientRequest, UrlParams, type HttpClientError, - type HttpClientRequest, type HttpClientResponse, } from '@effect/platform' import { diff } from 'deep-object-diff' @@ -37,14 +37,16 @@ export const CachingHttpClient: Effect.Effect< } else { yield* Effect.logDebug('Cache stale').pipe(Effect.annotateLogs(logAnnotations)) yield* Effect.forkDaemon( - Effect.gen(function* () { - yield* pipe( - req, - httpClient.execute, - Effect.tap(response => cache.set(response, DateTime.addDuration(timestamp, '10 seconds'))), - Effect.scoped, - ) - }), + pipe( + req, + httpClient.execute, + Effect.tap(response => cache.set(response, DateTime.addDuration(timestamp, '10 seconds'))), + Effect.scoped, + Effect.tapError(error => + Effect.logError('Unable to update cached response').pipe(Effect.annotateLogs({ error })), + ), + Effect.ignore, + ), ) } return response.response