fix(core): align terminal failures with current runner
This commit is contained in:
parent
cfab7a2d79
commit
aeaabc3928
3 changed files with 10 additions and 5 deletions
|
|
@ -124,7 +124,7 @@ export namespace Run {
|
||||||
...options,
|
...options,
|
||||||
schema: {
|
schema: {
|
||||||
...Base,
|
...Base,
|
||||||
reason: Schema.Literals(["execution-failed", "step-limit-exceeded", "unknown"]),
|
reason: Schema.Literals(["execution-failed", "unknown"]),
|
||||||
input: Schema.Struct({
|
input: Schema.Struct({
|
||||||
messageID: SessionMessageID.ID,
|
messageID: SessionMessageID.ID,
|
||||||
admittedSeq: NonNegativeInt,
|
admittedSeq: NonNegativeInt,
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ export const layer = Layer.effect(
|
||||||
yield* events.publish(SessionEvent.Run.Failed, {
|
yield* events.publish(SessionEvent.Run.Failed, {
|
||||||
sessionID,
|
sessionID,
|
||||||
timestamp: yield* DateTime.now,
|
timestamp: yield* DateTime.now,
|
||||||
reason: error instanceof SessionRunner.StepLimitExceededError ? "step-limit-exceeded" : "execution-failed",
|
reason: error === undefined ? "unknown" : "execution-failed",
|
||||||
...(input === undefined
|
...(input === undefined
|
||||||
? {}
|
? {}
|
||||||
: {
|
: {
|
||||||
|
|
|
||||||
|
|
@ -915,19 +915,24 @@ describe("SessionRunCoordinator", () => {
|
||||||
Effect.gen(function* () {
|
Effect.gen(function* () {
|
||||||
const failure = new Error("wake failed")
|
const failure = new Error("wake failed")
|
||||||
const reported: Cause.Cause<Error>[] = []
|
const reported: Cause.Cause<Error>[] = []
|
||||||
|
const contexts: Array<{ readonly mode: "wake"; readonly seq?: number }> = []
|
||||||
const reportedOnce = yield* Deferred.make<void>()
|
const reportedOnce = yield* Deferred.make<void>()
|
||||||
const coordinator = yield* SessionRunCoordinator.make<string, void, Error>({
|
const coordinator = yield* SessionRunCoordinator.make<string, void, Error>({
|
||||||
drain: () => Effect.fail(failure),
|
drain: () => Effect.fail(failure),
|
||||||
onFailure: (_key, cause) =>
|
onFailure: (_key, cause, context) =>
|
||||||
Effect.sync(() => reported.push(cause)).pipe(Effect.andThen(Deferred.succeed(reportedOnce, undefined))),
|
Effect.sync(() => {
|
||||||
|
reported.push(cause)
|
||||||
|
contexts.push(context)
|
||||||
|
}).pipe(Effect.andThen(Deferred.succeed(reportedOnce, undefined))),
|
||||||
})
|
})
|
||||||
|
|
||||||
yield* coordinator.wake("session")
|
yield* coordinator.wake("session", 7)
|
||||||
yield* Deferred.await(reportedOnce)
|
yield* Deferred.await(reportedOnce)
|
||||||
yield* Effect.yieldNow
|
yield* Effect.yieldNow
|
||||||
|
|
||||||
expect(reported).toHaveLength(1)
|
expect(reported).toHaveLength(1)
|
||||||
expect(Cause.squash(reported[0]!)).toBe(failure)
|
expect(Cause.squash(reported[0]!)).toBe(failure)
|
||||||
|
expect(contexts).toEqual([{ mode: "wake", seq: 7 }])
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue