Debugging `useDatabase` Utility with `Effect.tryPromise`

I've written a small utility that lets me use a service in a callback, and it doesn't work for some reason:
export const useDatabase = (runtime: Runtime) => (cb: (db: Kysely<DB>) => Promise<any>) =>
  runtime.runPromise(
    Effect.gen(function* () {
      const db = yield* Database;
      return Effect.tryPromise({ try: () => cb(db), catch: (err) => console.error(err) });
    })
  );

If I use this nothing happens, but if I do this:
export const useDatabase = (runtime: Runtime) => (cb: (db: Kysely<DB>) => Promise<any>) =>
  runtime.runPromise(
    Effect.gen(function* () {
      const db = yield* Database;

      cb(db); // TODO: remove

      return Effect.tryPromise({ try: () => cb(db), catch: (err) => console.error(err) });
    })
  );

it works. What am I doing wrong? Can I use tryPromise within a gen? Did I miss something?
Was this page helpful?