Commit 0bc18c4
fix: clear workflow status when an account precondition ends a run (Comfy-Org#15161)
## Summary
A runtime credits refusal leaves the workflow's execution status stuck
at `running` forever.
## Changes
- **What**: `handleAccountPreconditionError` in
`src/stores/executionStore.ts` now clears the workflow's
`workflowStatus` entry before resetting execution state.
Mechanism on `main`:
- `handleExecutionError` calls
`handleAccountPreconditionError(e.detail)` and returns early when it
returns true. These errors (`INSUFFICIENT_CREDITS` /
`WORKSPACE_INSUFFICIENT_CREDITS`, routed via
`resolveAccountPrecondition`) open their own modal and are deliberately
kept out of the error panel and error count.
- `handleAccountPreconditionError` only called
`clearInitializationByJobId` then `resetExecutionState`.
- `resetExecutionState` deletes `queuedJobs[jobId]` and the
`jobIdToWorkflow` entry, but never touches `workflowStatus`.
These are runtime errors: the job was accepted, got a machine, and
`execution_start` already wrote `running` before the refusal arrives. So
the status map keeps `running` indefinitely, and every reader of
`getWorkflowStatus` (status badges, the first-run tour result card)
promises a result that will never arrive.
`handleExecutionInterrupted` already does the right thing and is the
precedent this copies. Ordering matters: the `jobIdToWorkflow` lookup
and status clear must happen before `resetExecutionState`, which deletes
that mapping.
## Review Focus
- Clearing rather than writing `failed` is intentional and matches the
interrupt path — an account precondition is a gating state with its own
modal, not a workflow failure, so it should leave no badge.
- Sibling early-return branches (`handleServiceLevelError`,
`handleCloudValidationError`) were left alone. Service-level errors have
an existing test asserting the status stays `running`, so changing that
is a separate decision.
- Unit test added in `src/stores/executionStore.test.ts`: paid-style
credits payload after `execution_start`, asserting the status goes from
`running` to cleared. Verified it fails on `main` (`expected 'running'
to be undefined`) and passes with the fix.
Found while reviewing
Comfy-Org#15091. Distinct from
Comfy-Org#14619, which covers
the submit-time refusal where no `prompt_id` is ever issued and the
status never passes through `running` at all; this is the
accepted-then-refused runtime path.
Co-authored-by: Connor Byrne <c.byrne@comfy.org>1 parent 298b78a commit 0bc18c4
2 files changed
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
936 | 936 | | |
937 | 937 | | |
938 | 938 | | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
939 | 961 | | |
940 | 962 | | |
941 | 963 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
686 | 686 | | |
687 | 687 | | |
688 | 688 | | |
| 689 | + | |
| 690 | + | |
689 | 691 | | |
690 | 692 | | |
691 | 693 | | |
| |||
0 commit comments