Node 18 UND_ERR_HEADERS_TIMEOUT error encountered when calling Ollama invoke, even when overriding keepAlive default #5734
-
Checked other resources
Commit to Help
Example Codeconst ollama = new Ollama({
baseUrl: "http://127.0.0.1:11434",
model: "phi3",
options: {
"temperature": 1
}
});
ollama.invoke(prompt).then(res => ... DescriptionI am running a local Ollama server with hardware resource constraints, but I have verified the application has installed correctly and works from the CLI on this hardware, and the issue I have encountered does not occur on faster hardware. An associated nodejs application I wrote that simply invokes the model using langchain fails with an UND_ERR_HEADERS_TIMEOUT error complaining the fetch failed. And the stack points to line 12 in dist/utils/ollama.cjs, which is where the fetch occurs. My understanding based on related issues I've found during research is that this timeout can be extended using OLLAMA_KEEP_ALIVE, specifically this here: Assuming my understanding is correct, langchain does not honor a value I use to override this, neither inline with the LLM call nor when I set the OLLAMA_KEEP_ALIVE environment variable. The error surfaces after 5 minutes have passed from when I call invoke, which appears to be the default set here and also in the associated embeddings file. So assuming that the keep_alive property is indeed what I need to ensure the model has sufficient time under hardware constraints to complete a response and get a completion, what am I doing wrong? Thanks. System Infonode 18.20.3 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hello, @elliotrodriguez! I'm a bot that can help you with bug fixes, questions, and becoming a contributor. I'm here to assist you while waiting for a human maintainer. To properly override the const ollama = new Ollama({
baseUrl: "http://127.0.0.1:11434",
model: "phi3",
keepAlive: "10m", // Set the keepAlive timeout to 10 minutes
options: {
temperature: 1
}
});
ollama.invoke(prompt).then(res => {
// Handle the response
}).catch(err => {
// Handle the error
}); In this example, the Additionally, ensure that you are not setting the |
Beta Was this translation helpful? Give feedback.
-
This does not work. I've tried this before as well and neglected to mention it in my question: keepAlive:"30m" again based on my understanding of what this parameter does in context of the fetch, the above value should provide 30 minutes before timeout, but it reliably times out after 5 minutes. I've personally timed and observed the response.
There is a related issue here that mentions a fix: Which was not effective until I updated to node 20. So it would seem the solution is, for those who can, upgrade to node 20 until/unless something is done to address the fetch bug in node 18. |
Beta Was this translation helpful? Give feedback.
This does not work. I've tried this before as well and neglected to mention it in my question:
keepAlive:"30m"
again based on my understanding of what this parameter does in context of the fetch, the above value should provide 30 minutes before timeout, but it reliably times out after 5 minutes. I've personally timed and observed the response.