Skip to content

refactor(config): use cachedInvalidateWithTTL, bump effect to beta.37 - #19322

Merged
kitlangton merged 1 commit into
devfrom
kit/improve-config-effect
Mar 26, 2026
Merged

refactor(config): use cachedInvalidateWithTTL, bump effect to beta.37#19322
kitlangton merged 1 commit into
devfrom
kit/improve-config-effect

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

Summary

  • Replace mutable let cachedGlobal + reassignment pattern with Effect.cachedInvalidateWithTTL(effect, Duration.infinity) — uses the built-in invalidation effect instead of re-creating the cache on every invalidate call
  • Add Effect.tapError to log when global config loading fails before falling back to empty defaults (previously silent)
  • Bump effect and @effect/platform-node from 4.0.0-beta.354.0.0-beta.37

Details

The old pattern used a let binding that was reassigned in invalidate():

let cachedGlobal = yield* Effect.cached(loadGlobal().pipe(...))
// in invalidate():
cachedGlobal = yield* Effect.cached(loadGlobal().pipe(...))

The new pattern uses the idiomatic Effect primitive:

const [cachedGlobal, invalidateGlobal] = yield* Effect.cachedInvalidateWithTTL(
  loadGlobal().pipe(...),
  Duration.infinity,
)
// in invalidate():
yield* invalidateGlobal

Test plan

  • 127 config tests pass
  • 1526 total tests pass (full suite, 0 failures)
  • Typecheck clean
- Replace `let cachedGlobal` + reassignment with
  `Effect.cachedInvalidateWithTTL` + `Duration.infinity` — eliminates
  mutable binding and uses the idiomatic invalidation effect
- Add `Effect.tapError` to log when global config loading fails before
  falling back to empty defaults
- Remove unnecessary `as Info` cast on `orElseSucceed` fallback
- Bump effect 4.0.0-beta.35 → 4.0.0-beta.37
- Bump @effect/platform-node 4.0.0-beta.35 → 4.0.0-beta.37
@kitlangton
kitlangton enabled auto-merge (squash) March 26, 2026 17:58
@kitlangton
kitlangton merged commit 1ebc92f into dev Mar 26, 2026
12 checks passed
@kitlangton
kitlangton deleted the kit/improve-config-effect branch March 26, 2026 18:05
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
MarsQiu007 referenced this pull request in MarsQiu007/openNovel Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment