Skip to content
This repository was archived by the owner on Apr 4, 2026. It is now read-only.

fix: stop Flask API request FD growth under Docker load#19

Merged
Nafania merged 1 commit into
mainfrom
fix/fd-api-async-bridge-leak
Mar 25, 2026
Merged

fix: stop Flask API request FD growth under Docker load#19
Nafania merged 1 commit into
mainfrom
fix/fd-api-async-bridge-leak

Conversation

@Nafania
Copy link
Copy Markdown
Owner

@Nafania Nafania commented Mar 25, 2026

Summary

  • Route API handlers through explicit sync dispatch (asyncio.run) instead of Flask's implicit async bridge for registered API endpoints.
  • Make auth/loopback/CSRF decorators work for both sync and async handlers so the request pipeline remains consistent after dispatch change.
  • Add regression coverage that decorators also work on sync handlers.

Test plan

  • Build and run real app in Docker with OpenAI gpt-4o-mini for all models.
  • Reproduce baseline leak behavior on /health before fix (FD grows and does not settle).
  • Re-test after fix: 200x /health keeps FD flat (delta 0, then -1 after settle).
  • Re-test /poll + /history_get burst after fix: FD delta 0.
  • Re-test /message workload after fix: no monotonic growth on repeated rounds (warmup spikes settle; end delta near baseline).
  • pytest -q tests/api/test_http_auth_csrf.py in local host env (fails here due missing uvicorn dependency in host Python env).

Made with Cursor

Run API handlers through explicit sync dispatch and support both sync/async auth decorators so Flask no longer accumulates eventpoll/socket descriptors per request under Docker load.

Made-with: Cursor
@Nafania Nafania merged commit 2d939de into main Mar 25, 2026
4 checks passed
Nafania added a commit that referenced this pull request Mar 31, 2026
- #3: duplicate response loop breaker (breaks after 3 identical responses)
- #4: dynamic output truncation threshold based on context window size
- #2: resolve §§secret() / $$secret() placeholders in MCP server env/args/url/headers
- #19: scheduler update_task tool method + prompt documentation

Already applied (verified, skipping): #22 parallel MCP init, agent0ai#62 context window optimization

Upstream: PR agent0ai#1265, PR agent0ai#857, PR agent0ai#1150, PR agent0ai#1105
Made-with: Cursor
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant