`makeTrackExecutionUsage` lived in its own `services/autumn-tracker.ts` only to dodge the `api/layers.ts` → `@tanstack/react-start` import cycle that breaks vitest-pool-workers. It baked fire-and-forget semantics + error logging into the function shape — callers got back a `(id) => void` and couldn't compose or test the billing call. Moves the tracker onto the service itself as `AutumnService.trackExecution` (Effect shape, error channel `never`), matching the existing `use` method pattern. Callers now `Effect.runFork(autumn.trackExecution(id))` at the single boundary in `execution-stack.ts`, which is honest about the fire-and-forget choice happening at that layer — not in the service. - `services/autumn.ts`: adds `trackExecution` to `IAutumnService`. Errors are caught and logged; the returned Effect never fails. Wrapped in an `autumn.trackExecution` span so traces pick it up the same way the existing `use` calls do. - `services/execution-stack.ts`: inlines the `Effect.runFork` at the sole caller; drops the `autumn-tracker` import. - `api/autumn.ts`: drops the re-export that pointed at the old file. - Deletes `services/autumn-tracker.ts`.
Showing the changes to apps/cloud/src/api (1 of 4 files). Show all
Unified · Split
| @@ -8,12 +8,6 @@ import { AutumnService } from "../services/autumn"; · 7 unmodified lines | |||
| 8 | import { HttpResponseError, isServerError, toErrorServerResponse } from "./error-response"; | 8 | import { HttpResponseError, isServerError, toErrorServerResponse } from "./error-response"; |
| 9 | import { SharedServices } from "./layers"; | 9 | import { SharedServices } from "./layers"; |
| 10 | 10 | ||
| 11 | // Re-export so existing callers don't have to change their import path. | ||
| 12 | // The actual implementation moved to `services/autumn-tracker.ts` to break | ||
| 13 | // a DO → api/* → tanstack-start import cycle that crashed module load | ||
| 14 | // under vitest-pool-workers. | ||
| 15 | export { makeTrackExecutionUsage } from "../services/autumn-tracker"; | ||
| 16 | |||
| 17 | const handleAutumnRequestEffect = Effect.gen(function* () { | 11 | const handleAutumnRequestEffect = Effect.gen(function* () { |
| 18 | const request = yield* HttpServerRequest.HttpServerRequest; | 12 | const request = yield* HttpServerRequest.HttpServerRequest; |
| 19 | const webRequest = yield* Effect.mapError( | 13 | const webRequest = yield* Effect.mapError( |