Skip to content

bug: preserve invocation-owned log handlers across nested runs #341

Description

@codeforester

Problem

Nested calls to run_app() for the same CLI identity silently remove the outer invocation's logging handlers. ContextVars restore the outer Context, but configure_logger() and cleanup() operate on one process-global logger keyed only by CLI name.

Verified evidence

Reviewed on 2026-09-12 at 7faf347a5b90969e169c88f3ac18e7202d142dd0; the local checkout matches GitHub main.

Create an App named nested with default persistent logging and a boolean --inner option. Its outer callback logs before, invokes run_app(app, ["--inner", "--quiet"]), then logs after; the inner callback logs inner.

Observed: both calls return 0; outer primary.log contains before but no after; inner primary.log contains inner. The inner logger setup closes the outer handlers, and inner cleanup removes its replacements. No application logging exception is raised.

Sources:

Acceptance criteria

  • Either support nested same-identity runs with invocation-owned handlers/restoration or reject unsupported reentrancy before altering the outer run.
  • Document the in-process nesting/concurrency boundary.
  • Add regressions proving outer logs survive inner success and failure and handlers are closed exactly once.
  • Preserve existing multi-process logging behavior.

Project fields

  • Status: Backlog
  • Priority: P2
  • Area: Runtime
  • Initiative: v1.0 Readiness
  • Size: M
  • Assignee: @codeforester
  • Milestone: v1.0.0
  • Target date: unscheduled

Activity

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

Metadata

Metadata

Assignees

Labels

bugSomething is not working

Type

Projects

  • Status
    Backlog

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions