Understanding Scope Behavior in Effect System

Little confused with the scopes behaviour:
1) Why my program requires a scope to run it in the first case, if i already created the scope inside of it and provided it directly into Effect.forkIn
2) Why the finallizers in gameRunner have not been called in the first example when i close the scope after two seconds (it called properly in the second case)

to me this two cases are interchangeable but looks like i don't understand something 😕
const program = Effect.gen(function* (){
  const scope = yield* Scope.make();

  // 1 case: program requires a scope
  yield* Effect.forkIn(gameRunner, scope).pipe(Effect.withLogSpan('forkIn'))

  // 2 case: no scope required
  yield* pipe(
    gameRunner,
    Effect.fork,
    Scope.extend(scope),
    Effect.withLogSpan('Scope.extend')
  )

  yield* Effect.fork(
    Scope.close(scope, Exit.void).pipe(
      Effect.delay(Duration.seconds(2))
    ),
  )

  yield* Effect.never
})
Was this page helpful?