Child fiber outlives Parent fiber(?)

I have the following base of my service. I want to start an effect that takes long, but I want the method that starts it to return (ie respond to http request) without it interupting the forked effect.

How would I go about achieving this?
import { Console, Effect as E } from 'effect'

const process = (_: object) => E.gen(function*() {
    yield* Console.log("processing start")
    yield* E.sleep("2 seconds")
    yield* Console.log("processing end")

    // would post to some other service
    return "done"
})

const isValid = (msg: string) => E.gen(function*() {
    yield* Console.log(`message '${msg}' is valid `)
    return true
})

// mimic incomming data of http request
const body = { message: 'hi' }

// Mimic express endpoint handler
const start = E.gen(function*() {
    if (yield* isValid(body.message)) {
        // Q: how do I get this to run even if the calling function ends?
        E.fork(process(body))
        return 200
    } else {
        return 400
    }
})

E.runPromise(start)
Was this page helpful?