Skip to content

fix(runtime): await gateway telemetry shutdown - #442

Open
zhengdaqi wants to merge 2 commits into
mainfrom
codex/fix-gateway-telemetry-shutdown
Open

fix(runtime): await gateway telemetry shutdown#442
zhengdaqi wants to merge 2 commits into
mainfrom
codex/fix-gateway-telemetry-shutdown

Conversation

@zhengdaqi

Copy link
Copy Markdown
Collaborator

Summary

Make local gateway disposal await the owned telemetry shutdown and prevent disabled telemetry from creating a new empty queue file. This addresses the benchmark cleanup race where dispose() returned before telemetry/queue.jsonl was recreated, causing isolated PILOT_HOME removal to fail with ENOTEMPTY.

This branch includes the already independently tested network-timer fix from PR #441 as its local parent so repository-wide tests have a clean baseline. The telemetry changes are the second commit and can be reviewed independently.

Changes

  • Return an idempotent Promise from createLocalGateway().dispose() and await it in the server stop path.
  • Keep telemetry queue restoration compatible while avoiding writes from instances that were never enabled.
  • Add regression coverage for disabled shutdown, existing queue preservation, runtime re-enable persistence, and real gateway disposal.

QA & Evidence

  • What was tested: Focused telemetry and local-gateway tests.

  • Observed result: 4 passed, 0 failed, 0 cancelled.

  • Artifact: .omo/evidence/20260723-telemetry-shutdown/build-and-focused.txt

  • Why sufficient: Directly covers the observed queue-file race and the new awaitable/idempotent API.

  • What was tested: Complete npm test suite on the combined local branch.

  • Observed result: 149 passed, 0 failed, 0 cancelled, exit code 0.

  • Artifact: .omo/evidence/20260723-telemetry-shutdown/full-suite.txt

  • Why sufficient: Confirms no repository-wide regression after the parent timer baseline and telemetry lifecycle changes.

  • What was tested: Isolated real createLocalGateway() initialization and disposal with disabled telemetry.

  • Observed result: Calling dispose() twice returns the same Promise; awaiting it leaves no telemetry/queue.jsonl behind.

  • Artifact: .omo/evidence/20260723-telemetry-shutdown/build-and-focused.txt

  • Why sufficient: Exercises the actual gateway construction and shutdown surface rather than only mocking the sender.

Risks & Residuals

dispose() remains safe for existing callers that do not await it, while callers that need deterministic teardown can await the returned Promise. The gateway still does not own externally supplied telemetry; the server path continues to shut that client down separately. No credentials or external telemetry uploads were used.

Related

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant