Skip to content

Commit

Permalink
don't add proxy to FiberId
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Sep 12, 2024
1 parent ee5556f commit 95b51be
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
5 changes: 2 additions & 3 deletions packages/effect/src/internal/cause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const interrupt = (fiberId: FiberId.FiberId): Cause.Cause<never> => {
const o = Object.create(proto)
o._tag = OpCodes.OP_INTERRUPT
o.fiberId = fiberId
return rehydrateAnnotations(o, fiberId)
return o
}

/** @internal */
Expand Down Expand Up @@ -1304,8 +1304,7 @@ const AnnotationsReducer: Cause.CauseReducer<Context.Context<never>, unknown, Ca
emptyCase: (_) => empty,
failCase: (context, error, annotations) => fail(addOriginalAnnotations(error, Context.merge(context, annotations))),
dieCase: (context, defect, annotations) => die(addOriginalAnnotations(defect, Context.merge(context, annotations))),
interruptCase: (context, fiberId, annotations) =>
interrupt(addOriginalAnnotations(fiberId, Context.merge(context, annotations))),
interruptCase: (_, fiberId) => interrupt(fiberId),
sequentialCase: (_, left, right) => sequential(left, right),
parallelCase: (_, left, right) => parallel(left, right),
annotatedCase: (context, cause, annotations) => annotated(cause, Context.merge(context, annotations))
Expand Down
15 changes: 11 additions & 4 deletions packages/effect/src/internal/fiberRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,11 +493,18 @@ export class FiberRuntime<in out A, in out E = never> extends Effectable.Class<A
*/
interruptAsFork(fiberId: FiberId.FiberId): Effect.Effect<void> {
return core.withFiberRuntime<void>((fiber) => {
const span = fiber.currentSpan
if (span && span._tag === "Span") {
fiberId = internalCause.addOriginalAnnotation(fiberId, internalCause.InterruptorSpan, span)
let context = Context.empty()
if (fiber.currentSpan && fiber.currentSpan._tag === "Span") {
context = Context.add(context, internalCause.InterruptorSpan, fiber.currentSpan)
}
this.unsafeInterruptAsFork(fiberId)
if (this.currentSpan && this.currentSpan._tag === "Span") {
context = Context.add(context, internalCause.FailureSpan, this.currentSpan)
}
this.tell(FiberMessage.interruptSignal(
Context.isEmpty(context)
? internalCause.interrupt(fiberId)
: internalCause.annotated(internalCause.interrupt(fiberId), context)
))
return core.void
})
}
Expand Down

0 comments on commit 95b51be

Please sign in to comment.