Handling ConfigError in Layer.launch with Express integration

Hey everyone, I'm trying to understand how I can do some fatal error if a layer has an error, let me explain, I've taken the example from the documentation about Express integration and I end with this code (some part is not shown because not relevant imho):

export const ServerLive = Layer.scopedDiscard(
  Effect.gen(function* () {
    const { port } = yield* appConfig // <-- Take config
    const app = yield* Express
    yield* Effect.acquireRelease(
      Effect.sync(() => {
        app.listen(port, () =>
          console.log(`[Server] Listening on port ${port}`),
        )
      }),
      () => Effect.sync(() => console.log("[Server] Stopping server")),
    )
  }),
)

const AppLive = ServerLive.pipe(
  Layer.provide(RouterLive),
  Layer.provide(ExpressLive),
  Layer.provide(ServicesLive),
  Layer.provide(DatabaseLive),
) // <-- type is Layer.Layer<never, ConfigError, never>

// Does nothing about error
Effect.runFork(Layer.launch(AppLive))


The problem I have is that in the last line I use Layer.launch with the Layer, which may fail with ConfigError but nothing happens, if I run it with TS node it just exit, I would expect to have an error shown, how could i achieve this ? Thanks
Was this page helpful?