Skip to content

Commit

Permalink
fix fork semantics
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Jun 1, 2024
1 parent 548f88f commit b5473bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions packages/effect/src/Micro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2543,12 +2543,12 @@ export const fork = <A, E, R>(self: Micro<A, E, R>): Micro<Handle<A, E>, never,
map[currentAbortSignal.key] = handle._controller.signal
return map
})
Promise.resolve().then(() => {
yieldAdd(() => {
self[runSymbol](nextEnv, (result) => {
handle.emit(result)
})
onResult(Either.right(handle))
})
onResult(Either.right(handle))
})

/**
Expand All @@ -2564,12 +2564,12 @@ export const forkDaemon = <A, E, R>(self: Micro<A, E, R>): Micro<Handle<A, E>, n
map[currentAbortSignal.key] = controller.signal
return map
})
Promise.resolve().then(() => {
yieldAdd(() => {
self[runSymbol](nextEnv, (result) => {
handle.emit(result)
})
onResult(Either.right(handle))
})
onResult(Either.right(handle))
})

// ----------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions packages/effect/test/Micro.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ describe.sequential("Micro", () => {
release = true
})
).pipe(Micro.scoped, Micro.fork)
yield* Micro.yieldNow
handle.unsafeAbort()
yield* handle.await
assert.strictEqual(release, true)
Expand Down Expand Up @@ -468,8 +469,7 @@ describe.sequential("Micro", () => {
Micro.gen(function*() {
const error = yield* new TestError().pipe(Micro.flip)
assert.deepStrictEqual(error, new TestError())
assert.include(error.stack, "Micro.test.ts:469")
console.log(error.stack)
assert.include(error.stack, "Micro.test.ts:470")
}))

it.effect("is a valid Effect", () =>
Expand Down

0 comments on commit b5473bf

Please sign in to comment.