Skip to content

fix(coreapi): per-plugin Stop timeout in StopAll (PILOT-319)#13

Open
matthew-pilot wants to merge 1 commit into
mainfrom
openclaw/pilot-319-20260531-010650
Open

fix(coreapi): per-plugin Stop timeout in StopAll (PILOT-319)#13
matthew-pilot wants to merge 1 commit into
mainfrom
openclaw/pilot-319-20260531-010650

Conversation

@matthew-pilot
Copy link
Copy Markdown
Collaborator

What

StopAll was passing the same parent context to every plugin Stop call. A single hung plugin would block all remaining plugins from shutting down.

Why

Per-plugin context.WithTimeout(ctx, 5*time.Second) ensures each plugin gets its own 5-second deadline. If a plugin exceeds it, context.DeadlineExceeded is surfaced as a Stop error, the error is collected, and subsequent plugins continue shutting down.

Verification

  • go build ./... — passes
  • go vet ./... — clean
  • go test ./... — all 13 packages green
  • Added TestServiceRegistry_StopAllTimingOutHangingPlugin that verifies a hanging plugin times out and later-ordered services still stop

Closes PILOT-319

StopAll was passing the same parent context to every plugin Stop
call. A single hung plugin (blocked indefinitely in its Stop
method) would prevent all remaining plugins from shutting down.

Fix: derive a 5-second timeout context per plugin Stop call via
context.WithTimeout. If a plugin exceeds the deadline, its Stop
returns context.DeadlineExceeded, the error is collected, and
remaining plugins continue shutting down. This matches the
Service contract comment ("must return within 5 seconds").

Includes TestServiceRegistry_StopAllTimingOutHangingPlugin that
verifies a hanging plugin times out and subsequent plugins still
receive their Stop call.

Closes PILOT-319
@codecov
Copy link
Copy Markdown

codecov Bot commented May 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@matthew-pilot
Copy link
Copy Markdown
Collaborator Author

🤖 PR Status — matthew-pr-worker

PR: #13fix(coreapi): per-plugin Stop timeout in StopAll (PILOT-319)
Branch: openclaw/pilot-319-20260531-010650main
Author: matthew-pilot | State: OPEN | Mergeable: ✅ MERGEABLE
Diff: +48 −4 across 2 files

CI Summary

Check Status
test ✅ SUCCESS
codecov/patch ✅ SUCCESS

2/2 passing — all green.

Files Changed

  • coreapi/lifecycle.go (+14/−4)
  • coreapi/zz_lifecycle_edge_test.go (+34/0)

Bot dispatched by matthew-pr-worker • 2026-05-31T01:11:00Z

@matthew-pilot
Copy link
Copy Markdown
Collaborator Author

🔍 PR Explanation — matthew-pr-worker

What this PR changes

coreapi/lifecycle.go: The StopAll method previously passed the same parent context to every plugin Stop call. If a single plugin hung during Stop, all remaining plugins were blocked from shutting down. This PR wraps each Stop call in context.WithTimeout(ctx, 5*time.Second) so each plugin gets a dedicated 5-second deadline. If a plugin exceeds it, context.DeadlineExceeded is surfaced as a Stop error, collected, and the loop continues to shut down remaining plugins.

Why it matters

A hung plugin during shutdown could block the entire process teardown — a graceful-shutdown DoS vector. Per-plugin timeouts prevent one misbehaving plugin from holding up the whole stop sequence.

Risk assessment

  • Low risk: The change is narrowly scoped to the shutdown path (StopAll).
  • Backwards-compatible: Existing plugins still get Stop called; the only addition is a timeout wrapper.
  • Test coverage: Includes a new test TestServiceRegistry_StopAllTimingOutHangingPlugin that verifies a hanging plugin times out and later-ordered services still stop.

Verification

  • go build ./... — passes
  • go vet ./... — clean
  • go test ./... — all packages green
  • CI: 2/2 passing (test ✅, codecov/patch ✅)

Ticket

Closes PILOT-319

Bot dispatched by matthew-pr-worker • 2026-05-31T01:11:00Z

@matthew-pilot
Copy link
Copy Markdown
Collaborator Author

📊 Matthew Status — PR #13 (PILOT-319)

State: OPEN · MERGEABLE ✅ · No merge conflicts
Canary: Not run (no canary workflow triggered)
Jira: PILOT-319 — QA/IN-REVIEW · Assigned to Teodor Calin · Last Jira update 2026-05-31
Operator activity: No operator review comments yet — PR has bot-only comments (codecov, matthew-pilot status/explain). Awaiting human review.
Labels: (none) · CI: 2/2 green

📅 Tick: 2026-06-01T02:13Z

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