(
f: <E, A>(
options: {
readonly fiber: Fiber.Fiber<A, E>
readonly teardown: Teardown
}
) => void
)
| 179 | * @since 4.0.0 |
| 180 | */ |
| 181 | export const makeRunMain = ( |
| 182 | f: <E, A>( |
| 183 | options: { |
| 184 | readonly fiber: Fiber.Fiber<A, E> |
| 185 | readonly teardown: Teardown |
| 186 | } |
| 187 | ) => void |
| 188 | ): { |
| 189 | ( |
| 190 | options?: { |
| 191 | readonly disableErrorReporting?: boolean | undefined |
| 192 | readonly teardown?: Teardown | undefined |
| 193 | } |
| 194 | ): <E, A>(effect: Effect.Effect<A, E>) => void |
| 195 | <E, A>( |
| 196 | effect: Effect.Effect<A, E>, |
| 197 | options?: { |
| 198 | readonly disableErrorReporting?: boolean | undefined |
| 199 | readonly teardown?: Teardown | undefined |
| 200 | } |
| 201 | ): void |
| 202 | } => |
| 203 | dual((args) => Effect.isEffect(args[0]), (effect: Effect.Effect<any, any>, options?: { |
| 204 | readonly disableErrorReporting?: boolean | undefined |
| 205 | readonly teardown?: Teardown | undefined |
| 206 | }) => { |
| 207 | const fiber = options?.disableErrorReporting === true |
| 208 | ? Effect.runFork(effect) |
| 209 | : Effect.runFork( |
| 210 | Effect.tapCause(effect, (cause) => { |
| 211 | if (Cause.hasInterruptsOnly(cause)) return Effect.void |
| 212 | const isReported = getErrorReported(Cause.squash(cause)) |
| 213 | return isReported ? Effect.logError(cause) : Effect.void |
| 214 | }) |
| 215 | ) |
| 216 | try { |
| 217 | const keepAlive = globalThis.setInterval(constVoid, 2_147_483_647) |
| 218 | fiber.addObserver(() => { |
| 219 | clearInterval(keepAlive) |
| 220 | }) |
| 221 | } catch {} |
| 222 | const teardown = options?.teardown ?? defaultTeardown |
| 223 | return f({ fiber, teardown }) |
| 224 | }) |
| 225 | |
| 226 | declare global { |
| 227 | interface Error { |
no test coverage detected