Skip to content

Nothing fails when aiogram reaches the API's cold start #272

Closed

Description

@lumenpearson

The API's cold start is kept free of aiogram on purpose, and nothing checks it. app/main.py mounts the webhook only when it is configured, app/api/telegram.py imports app.bot.bot inside _instances(), and _build_bot is imported lazily in app/api/edit.py, app/api/cron.py and app/api/manage/requests.py — CLAUDE.md says why: aiogram on that path is a slower start for every request that never touches the bot. tests/test_service_layering.py keeps app.bot out of services/, but it reads source for that one rule; no test imports app.main and asks whether aiogram came with it.

Failure scenario. A refactor adds from app.bot.render import more_line at the top of an API module, or a package __init__ re-exports a bot helper next to an API one. Every test passes; production's cold start now imports aiogram and its dependencies on every fresh Vercel instance, and the first sign is latency nobody can attribute.

The risk grows with the work planned next: the server decomposition and the new rpc/ and rest/ packages of docs/specs/2026-10-03-one-contract-design.md add exactly the kind of new modules and re-exporting __init__ files that carry an import in by accident.

Fix. A test that imports app.main in a fresh interpreter (a subprocess, so earlier tests' imports do not count) and fails if aiogram is in sys.modules; the layering rule extended to the new packages when they exist.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status
      Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions