diff --git a/packages/effect-fc/src/Query.ts b/packages/effect-fc/src/Query.ts index 32421f3..15d3efd 100644 --- a/packages/effect-fc/src/Query.ts +++ b/packages/effect-fc/src/Query.ts @@ -59,18 +59,17 @@ extends Pipeable.Class() implements Query { } get run(): Effect.Effect { - return Effect.provide( - Stream.runForEach(this.key, key => this.interrupt.pipe( - Effect.andThen(SubscriptionRef.set(this.latestKey, Option.some(key))), - Effect.andThen(this.latestFinalResult), - Effect.andThen(previous => this.startCached(key, Option.isSome(previous) - ? Result.willFetch(previous.value) as Result.Final - : Result.initial() - )), - Effect.andThen(sub => Effect.forkScoped(this.watch(key, sub))), - this.runSemaphore.withPermits(1), + return Stream.runForEach(this.key, key => this.interrupt.pipe( + Effect.andThen(SubscriptionRef.set(this.latestKey, Option.some(key))), + Effect.andThen(this.latestFinalResult), + Effect.andThen(previous => this.startCached(key, Option.isSome(previous) + ? Result.willFetch(previous.value) as Result.Final + : Result.initial() )), - this.context, + Effect.andThen(sub => Effect.forkScoped(this.watch(key, sub))), + )).pipe( + this.runSemaphore.withPermits(1), + Effect.provide(this.context), ) }