Skip to content

feat!: LabDropGuard with FlushRegistry for guaranteed clean shutdown#29

Merged
Frando merged 1 commit intomainfrom
fix/lab-drop-guard
Apr 13, 2026
Merged

feat!: LabDropGuard with FlushRegistry for guaranteed clean shutdown#29
Frando merged 1 commit intomainfrom
fix/lab-drop-guard

Conversation

@Frando
Copy link
Copy Markdown
Member

@Frando Frando commented Apr 13, 2026

Wrap Lab around Arc which derefs to LabInner. When the last Lab clone drops, the guard cancels all namespace workers (async runtimes + sync workers), flushes all buffered log files via a FlushRegistry, and writes the final state.json with the correct test status.

Device, Router, and Iface handles hold Arc directly, bypassing the guard. They do not prevent shutdown. This fixes an issue where outstanding handles could delay LabInner::drop, leaving state.json with status "running" and events.jsonl incompletely flushed.

The FlushRegistry collects all buffered file writers (events.jsonl, per-namespace tracing/ANSI/events/metrics logs) and flushes them synchronously in the drop guard.

Breaking changes

  • Removed: Device::lab(). Returned a Lab clone but could not safely participate in the drop guard lifecycle. Never called externally.
  • Removed: Router::lab(). Same reason.

@Frando Frando force-pushed the fix/lab-drop-guard branch 5 times, most recently from 3239e7e to d4e2df7 Compare April 13, 2026 22:22
Wrap Lab around Arc<LabDropGuard> which derefs to LabInner. When the
last Lab clone drops, the guard cancels all async and sync workers,
flushes all buffered log files, and writes the final state.json.

Device/Router/Iface handles hold Arc<LabInner> directly and do not
prevent shutdown.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Frando Frando changed the title fix: guarantee clean shutdown via LabDropGuard feat!: LabDropGuard with FlushRegistry for guaranteed clean shutdown Apr 13, 2026
@Frando Frando force-pushed the fix/lab-drop-guard branch from d4e2df7 to b7a1f85 Compare April 13, 2026 22:31
@Frando Frando merged commit 4973d10 into main Apr 13, 2026
3 checks passed
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