Cache lookup span not associated with parent
I would expect the following code
to produce 1 trace:
but instead it produces 2:
Could this be a bug, or is there something else I'm not understanding?
export class FooAuth extends Effect.Service<FooAuth>()("app/FooAuth", {
effect: Effect.gen(function*() {
const tokenCache = yield* Cache.make({
capacity: 1,
timeToLive: Duration.minutes(30),
lookup: Effect.fn("FooAuth.refreshToken")(function*(_: void) {
yield* Effect.sleep("2 seconds")
return "some-token"
})
})
const getToken = Effect.fn("FooAuth.getToken")(function*() {
return yield* tokenCache.get()
})
return { getToken } as const
}),
dependencies: []
}) {}
const program = Effect.gen(function*() {
const { getToken } = yield* FooAuth
yield* getToken()
}).pipe(Effect.withSpan("program"))export class FooAuth extends Effect.Service<FooAuth>()("app/FooAuth", {
effect: Effect.gen(function*() {
const tokenCache = yield* Cache.make({
capacity: 1,
timeToLive: Duration.minutes(30),
lookup: Effect.fn("FooAuth.refreshToken")(function*(_: void) {
yield* Effect.sleep("2 seconds")
return "some-token"
})
})
const getToken = Effect.fn("FooAuth.getToken")(function*() {
return yield* tokenCache.get()
})
return { getToken } as const
}),
dependencies: []
}) {}
const program = Effect.gen(function*() {
const { getToken } = yield* FooAuth
yield* getToken()
}).pipe(Effect.withSpan("program"))to produce 1 trace:
program -> FooAuth.getToken -> FooAuth.refreshTokenprogram -> FooAuth.getToken -> FooAuth.refreshTokenbut instead it produces 2:
program -> FooAuth.getToken
FooAuth.refreshTokenprogram -> FooAuth.getToken
FooAuth.refreshTokenCould this be a bug, or is there something else I'm not understanding?
