@@ -40,7 +40,7 @@ import { Lock } from "@/util/lock"
4040import { AppFileSystem } from "@/filesystem"
4141import { InstanceState } from "@/effect/instance-state"
4242import { makeRuntime } from "@/effect/run-service"
43- import { Effect , Layer , ServiceMap } from "effect"
43+ import { Duration , Effect , Layer , ServiceMap } from "effect"
4444
4545export namespace Config {
4646 const ModelId = z . string ( ) . meta ( { $ref : "https://models.dev/model-schema.json#/$defs/Model" } )
@@ -1241,7 +1241,15 @@ export namespace Config {
12411241 return result
12421242 } )
12431243
1244- let cachedGlobal = yield * Effect . cached ( loadGlobal ( ) . pipe ( Effect . orElseSucceed ( ( ) => ( { } ) as Info ) ) )
1244+ const [ cachedGlobal , invalidateGlobal ] = yield * Effect . cachedInvalidateWithTTL (
1245+ loadGlobal ( ) . pipe (
1246+ Effect . tapError ( ( error ) =>
1247+ Effect . sync ( ( ) => log . error ( "failed to load global config, using defaults" , { error : String ( error ) } ) ) ,
1248+ ) ,
1249+ Effect . orElseSucceed ( ( ) : Info => ( { } ) ) ,
1250+ ) ,
1251+ Duration . infinity ,
1252+ )
12451253
12461254 const getGlobal = Effect . fn ( "Config.getGlobal" ) ( function * ( ) {
12471255 return yield * cachedGlobal
@@ -1446,7 +1454,7 @@ export namespace Config {
14461454 } )
14471455
14481456 const invalidate = Effect . fn ( "Config.invalidate" ) ( function * ( wait ?: boolean ) {
1449- cachedGlobal = yield * Effect . cached ( loadGlobal ( ) . pipe ( Effect . orElseSucceed ( ( ) => ( { } ) as Info ) ) )
1457+ yield * invalidateGlobal
14501458 const task = Instance . disposeAll ( )
14511459 . catch ( ( ) => undefined )
14521460 . finally ( ( ) =>
0 commit comments