refactor(llama-cpp): clarify terminal cleanup contract

This commit is contained in:
Vincent Koc
2026-08-04 23:12:06 +08:00
parent 21e52da0cf
commit de8afade57
2 changed files with 4 additions and 3 deletions
@@ -937,7 +937,7 @@ describe("llama.cpp inference provider", () => {
expect(mocks.llamaDispose).toHaveBeenCalledOnce();
});
it("keeps a failed best-effort cleanup as one disposal attempt", async () => {
it("keeps a failed cleanup terminal", async () => {
await collectTestEvents();
mocks.contextDispose.mockRejectedValueOnce(new Error("context cleanup failed"));
@@ -307,8 +307,9 @@ function disposeLlamaCppInferenceRuntime(state: LlamaCppInferenceRuntimeState):
return state.disposePromise;
}
state.lifecycle = "closing";
// Plugin services stop once, and node-llama-cpp disposers mark themselves
// disposed before awaiting cleanup. The first disposal attempt is authoritative.
// node-llama-cpp disposers are one-shot and child cleanup releases the
// parent's disposal guard. Do not force parent cleanup after a child rejects:
// the retained guard can make that parent disposer wait forever.
state.disposePromise = serialize(state, async () => {
await disposeLoadedModel(state);
if (state.llamaInstance) {