Skip to content

gateway: thread --timeout flag into DispatcherManager (fixes #894)#895

Closed
Harishkrishna17 wants to merge 1 commit into
trustgraph-ai:release/v2.4from
Harishkrishna17:fix/gateway-dispatcher-timeout
Closed

gateway: thread --timeout flag into DispatcherManager (fixes #894)#895
Harishkrishna17 wants to merge 1 commit into
trustgraph-ai:release/v2.4from
Harishkrishna17:fix/gateway-dispatcher-timeout

Conversation

@Harishkrishna17

Copy link
Copy Markdown

Fixes #894.

Problem

The api-gateway accepts a --timeout flag (default 600,
gateway/service.py:36)
documented as "API request timeout in seconds", but the value
never reaches DispatcherManager, which constructs every per-service
dispatcher with a hardcoded timeout = 120. So --timeout 600 (or
any other value) had no effect on graph-rag, document-rag, librarian,
text-completion, or any other request/response path. Long-running
requests deterministically returned
{"error":{"type":"gateway-error","message":"Timeout"}} at exactly
2:00 wallclock, regardless of the gateway flag.

The WebSocket endpoint manager already received self.timeout
correctly; only the dispatcher manager was missing the wiring.

Change

  • Add timeout=120 parameter to DispatcherManager.__init__
    (default preserves prior behaviour for any external caller).
  • Store on self.timeout.
  • Use self.timeout in both dispatcher construction sites
    (global_dispatchers at line ~301 and request_response_dispatchers
    at line ~458) instead of the literal 120.
  • Pass timeout=self.timeout from Api in
    gateway/service.py:116-122 so the existing --timeout CLI flag
    finally reaches the dispatchers.

Compatibility

Non-breaking: default of 120 is preserved on the new parameter, so
any caller that doesn't pass timeout keeps the previous behaviour.

Test plan

  • Syntax-check both files (python -m py_compile).
  • Manual repro before fix on TG 2.3.21 with --timeout 600:
    curl … /api/v1/flow/default/service/graph-rag … returns
    gateway-error: Timeout at 120s.
  • After patch (verified by patching the same files in the
    running container before forking), the same query is allowed
    to run to completion (~25s server-side) and returns the
    grounded answer.
  • Maintainers: please confirm the existing dispatcher unit
    tests still pass; I haven't run the suite locally because
    this is targeted at release/v2.4 which I don't have a
    complete test env for.

Related

…ph-ai#894)

The api-gateway accepts a --timeout flag (default 600s) but
DispatcherManager never received it and instantiated every
per-service dispatcher with a hardcoded timeout=120. The flag
was therefore silently ignored for all per-service paths
(graph-rag, document-rag, librarian, etc.); requests over 120s
returned {"error":{"type":"gateway-error","message":"Timeout"}}
regardless of the configured value.

This adds a timeout parameter to DispatcherManager.__init__
(default 120 to preserve existing behaviour for callers that
don't pass it), stores it on self.timeout, uses it in both
dispatcher construction sites, and threads self.timeout through
from gateway/service.py where DispatcherManager is instantiated.

The default of 120 is preserved so this is a non-breaking
change. Callers that already pass timeout (none upstream today)
continue to work.
@github-actions

github-actions Bot commented May 9, 2026

Copy link
Copy Markdown

Contributor License Agreement

Thank you for your contribution! Before we can accept it, the following contributor(s) must sign our CLA:

@Harishkrishna17

Please read the appropriate agreement:

  • Contributing as an individual? Read the Individual CLA
  • Contributing on behalf of a company or organisation? Read the Entity CLA

Once you have read the appropriate agreement, post the following as a comment on this PR (copy and paste exactly):

I have read the CLA Document and I hereby sign the CLA

The bot will record your signature and update this PR automatically.

@cybermaggedon

Copy link
Copy Markdown
Contributor

Possible overlap: #931

@cybermaggedon

Copy link
Copy Markdown
Contributor

Stale, and possibly fixed elsewhere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants