Skip to content

bug(logger): close() never resolves under workerd once the logger is initialized #342

Description

@cyanheads

mcp-ts-core version

0.11.2

Runtime

Cloudflare Workers

Runtime version

workerd via @cloudflare/vitest-pool-workers

Transport

Worker (Cloudflare)

OS

macOS 15.x

Description

After logger initialization under workerd, Logger.close() can wait indefinitely for Pino flush callbacks. Any shutdown path awaiting it can hang.

Reproduction

Under vitest.worker.ts, make any request through a Worker handler, await the execution context, then call await logger.close() with a 10-second test timeout.

Actual behavior

close() does not settle after initialization because the main and interaction pino.flush(cb) callbacks do not run in workerd.

Expected behavior

Logger shutdown settles after a bounded opportunity to flush on every supported runtime.

Additional context

Related: #322 covers EOF bypassing shutdown; this issue covers shutdown blocking once reached.

Acceptance criteria

  • Initialized Worker logger shutdown settles within a bounded test timeout.
  • Completing Node and Bun flush callbacks are still awaited.
  • ServerHandle.shutdown() completes through logger shutdown.
  • Repeated close() calls remain safe.

Scope

  • Bound logger draining without changing normal completed-flush behavior.

Out of scope

  • Log destinations, levels, and public logger API changes.

Touchpoints

  • src/utils/internal/logger.ts, src/core/app.ts
  • Worker logger/shutdown tests, skills/api-telemetry/SKILL.md, changelog entry

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions