Skip to content

Commit 6db846b

Browse files
ELin2025claude
andcommitted
fix(frontend): add finalize guard to model fetch for cancellation cleanup
Mirror the defensive pattern from the tasks fetch so that when takeUntil(destroy$) cancels mid-flight, inFlightByTag is cleared and subsequent component instances can re-fetch instead of polling forever. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 94219f2 commit 6db846b

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

frontend/src/app/workspace/component/hugging-face/hugging-face.component.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,16 @@ export class HuggingFaceComponent extends FieldType<FieldTypeConfig> implements
360360
`${AppSettings.getApiEndpoint()}/huggingface/models?task=${encodeURIComponent(tag)}`,
361361
{ observe: "response" }
362362
)
363-
.pipe(takeUntil(this.destroy$))
363+
.pipe(
364+
takeUntil(this.destroy$),
365+
finalize(() => {
366+
// If takeUntil cancels before next/error fires, clear the in-flight
367+
// guard so a later instance re-fetches instead of polling forever.
368+
if (!allModelsByTag.has(tag) && !errorByTag.has(tag)) {
369+
inFlightByTag.delete(tag);
370+
}
371+
})
372+
)
364373
.subscribe({
365374
next: resp => {
366375
const models = resp.body ?? [];

0 commit comments

Comments
 (0)