Skip to content

Commit

Permalink
Let us know if the cache entry reloading fails
Browse files Browse the repository at this point in the history
Refs #2186
  • Loading branch information
thewilkybarkid committed Jan 17, 2025
1 parent 676ebd2 commit 0125c70
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/CachingHttpClient.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {

Check failure on line 1 in src/CachingHttpClient.ts

View workflow job for this annotation

GitHub Actions / Lint TypeScript

Imports "HttpClientRequest" are only used as type
HttpClient,
HttpClientRequest,
UrlParams,
type HttpClientError,
type HttpClientRequest,
type HttpClientResponse,
} from '@effect/platform'
import { diff } from 'deep-object-diff'
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0125c70

Please sign in to comment.