[GH-ISSUE #2876] REST APIs Request Cancellation #1757

Closed
opened 2026-04-12 11:46:02 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @mAlaliSy on GitHub (Mar 2, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/2876

Hi there,
I am using Ollama and I found it awesome.

One question, when calling Ollama using REST APIs (i.e. generate API), if the client cancels the HTTP request, will Ollama stop processing the request?

I found this issue here for JS client library https://github.com/ollama/ollama-js/issues/39 but it doesn't mention what happens on the server when the client abort the request.

Originally created by @mAlaliSy on GitHub (Mar 2, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/2876 Hi there, I am using Ollama and I found it awesome. One question, when calling Ollama using REST APIs (i.e. generate API), if the client cancels the HTTP request, will Ollama stop processing the request? I found this issue here for JS client library https://github.com/ollama/ollama-js/issues/39 but it doesn't mention what happens on the server when the client abort the request.
Author
Owner

@mmo80 commented on GitHub (Mar 2, 2024):

In my experience, yes, the server stops responding (not crashing) to the request if it is cancelled. That's what I see in the Ollama server logs when, for example, a stream fetch is cancelled (using AbortController); the server immediately stops responding.

<!-- gh-comment-id:1974835142 --> @mmo80 commented on GitHub (Mar 2, 2024): In my experience, yes, the server stops responding (not crashing) to the request if it is cancelled. That's what I see in the Ollama server logs when, for example, a stream fetch is cancelled (using [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController)); the server immediately stops responding.
Author
Owner

@jmorganca commented on GitHub (Mar 12, 2024):

Yes! If you abort the request Ollama will stop generation. Hope this helps!

<!-- gh-comment-id:1989771389 --> @jmorganca commented on GitHub (Mar 12, 2024): Yes! If you abort the request Ollama will stop generation. Hope this helps!
Author
Owner

@nkeilar commented on GitHub (Mar 25, 2024):

@jmorganca I've found that it doesn't stop in all cases. If some of the work is offloaded to the CPU, it seems to continue executing. This may have fried my CPU as it kept running without my knowledge while I was away, and probably didn't have adequate cooling in the room (13900k). Just replaced cpu and mobo. And am anxious that its its just going to run endlessly doing long generations on CPU. Need confidence that it stops when stream is closed, or stop button pressed.

This was verified below my comment here: https://github.com/open-webui/open-webui/issues/1166#issuecomment-2016954654 - actually reporting, as had significant financial cost to me.

Specifically I was using the professor model, quantised to 2 bits to fit on dual GPU, but it doesn't quite fit so I am offloading a bunch of layers to the CPU. I tested after replacing my CPU and Mobo, and its still occurring.

<!-- gh-comment-id:2017043630 --> @nkeilar commented on GitHub (Mar 25, 2024): @jmorganca I've found that it doesn't stop in all cases. If some of the work is offloaded to the CPU, it seems to continue executing. This may have fried my CPU as it kept running without my knowledge while I was away, and probably didn't have adequate cooling in the room (13900k). Just replaced cpu and mobo. And am anxious that its its just going to run endlessly doing long generations on CPU. Need confidence that it stops when stream is closed, or stop button pressed. This was verified below my comment here: https://github.com/open-webui/open-webui/issues/1166#issuecomment-2016954654 - actually reporting, as had significant financial cost to me. Specifically I was using the professor model, quantised to 2 bits to fit on dual GPU, but it doesn't quite fit so I am offloading a bunch of layers to the CPU. I tested after replacing my CPU and Mobo, and its still occurring.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#1757