Skip to content

Commit

Permalink
fix RC access
Browse files Browse the repository at this point in the history
  • Loading branch information
patroza committed Nov 10, 2023
1 parent 8d3fdbf commit 319a883
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/big-peas-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect-app/infra": patch
---

fix rc access
14 changes: 9 additions & 5 deletions packages/infra/_src/logger/shared.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { RuntimeFlags } from "effect"
import * as FiberRefs from "effect/FiberRefs"
import { RequestContextContainer } from "../services/RequestContextContainer.js"

export function getRequestContext(context: FiberRefs.FiberRefs) {
const ctx = FiberRefs.getOrDefault(context, FiberRef.currentContext)
// TODO: use `RequestContext.Tag` once switched?
const a = ctx.getOption(RequestContextContainer)
const c = a.map((_) => _.requestContext.runSync)
export function getRequestContext(fiberRefs: FiberRefs.FiberRefs) {
const context = FiberRefs.getOrDefault(fiberRefs, FiberRef.currentContext)
const a = context.getOption(RequestContextContainer)
const c = a.map((_) => {
// TODO: perhaps a litle expensive?
const rt = Runtime.make({ context, fiberRefs, runtimeFlags: RuntimeFlags.none })
return rt.runSync(_.requestContext)
})
return c
}

0 comments on commit 319a883

Please sign in to comment.