Skip to content

fix(embeddings): time out hung Ollama requests - #202

Merged
PatrickSys merged 2 commits into
masterfrom
fix/ollama-request-timeouts-20261204
Dec 4, 2026
Merged

PatrickSys merged 2 commits into
masterfrom
fix/ollama-request-timeouts-20261204

Conversation

@PatrickSys

Copy link
Copy Markdown
Owner

The review of #146 flagged that a stalled Ollama server could leave indexing waiting indefinitely. Both /api/show and /api/embed now have a per-request deadline that covers waiting for headers and reading the response body. A timeout reports the server, endpoint, and deadline.

The default is 120 seconds. Set OLLAMA_REQUEST_TIMEOUT_MS to override it, or set embedding.requestTimeoutMs when configuring the indexer in code.

  • Before the fix, four loopback regressions hit the test guard. With the fix, all 19 focused tests passed.
  • pnpm test passed 167 files and 1,540 tests, with 2 skipped and 0 failed.
  • pnpm type-check and pnpm format:check passed.

Agent: Codex 01a23fb0-312d-7822-9166-ea3b2e2f0763
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-04T06:36:25.068144Z e62a481 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5RetriggerView in Greptile

[Medium impact] The change affects Ollama-backed embedding workflows, from indexing calls to provider setup.

The PR appears safe to merge, with a non-blocking request to test timeout defaults and invalid values.

Findings

  1. P2 Timeout settings lack edge-case tests ▶

Summary

Adds deadlines to Ollama model checks and embedding requests.

  • Ollama requests stop when their configured deadline runs out.

Reviews (1) · Last reviewed commit: "fix(embeddings): time out hung Ollama re..." · Reviewed by Greptile

Comment thread src/embeddings/types.ts
Comment on lines +71 to +81
export function resolveOllamaRequestTimeoutMs(configured?: number): number {
const timeoutMs = configured ?? Number(process.env.OLLAMA_REQUEST_TIMEOUT_MS);
if (Number.isInteger(timeoutMs) && timeoutMs > 0 && timeoutMs <= MAX_TIMER_DELAY_MS) {
return timeoutMs;
}
if (configured !== undefined) {
throw new RangeError(
`Ollama requestTimeoutMs must be an integer from 1 to ${MAX_TIMER_DELAY_MS}`
);
}
return DEFAULT_OLLAMA_REQUEST_TIMEOUT_MS;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Timeout settings lack edge-case tests

resolveOllamaRequestTimeoutMs adds three untested behaviors: the 120-second default, fallback for invalid environment values, and rejection of invalid explicit values. The new tests use only valid overrides.

Add table-driven tests for unset values, zero, negative numbers, fractions, non-numbers, and the timer limit. These would catch changes that silently alter the deadline or let an invalid delay reach AbortSignal.timeout.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Agent: Codex 01a23fd8-6141-77b1-823b-9ae174818da1
@PatrickSys

Copy link
Copy Markdown
Owner Author

Added regression coverage for both review items.

  • The Ollama timeout resolver tests cover the 120-second default, both valid bounds, rejected explicit values, and environment fallback.
  • The indexer test verifies that embedding.requestTimeoutMs reaches the Ollama request and takes precedence over the environment setting.

The full local suite passed with 1,555 tests passed and 2 skipped.

@PatrickSys
PatrickSys merged commit 81f649c into master Dec 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant