Skip to content

fix(e2e): share ClawHub preflight timeout across fetch and body - #109045

Closed
hugenshen wants to merge 1 commit into
openclaw:mainfrom
hugenshen:fix/clawhub-preflight
Closed

hugenshen wants to merge 1 commit into
openclaw:mainfrom
hugenshen:fix/clawhub-preflight

Conversation

@hugenshen

@hugenshen hugenshen commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

ClawHub package preflight in the plugins E2E helper stacked separate deadlines for
HTTP fetch, bounded body read, and JSON parse. A slow header phase plus a stalled
body could therefore consume more than one configured
OPENCLAW_PLUGINS_E2E_CLAWHUB_PREFLIGHT_TIMEOUT_MS budget before failing.

Why This Change Was Made

Put fetch, readBoundedResponseText, and JSON.parse under one outer
withTimeout whose timeoutPromise is also passed into the bounded reader.
timeoutMs is a total wall-clock budget for the preflight, not a per-phase
allowance.

User Impact

No end-user product change. Plugin E2E ClawHub preflight fails closed within one
configured deadline when package metadata headers or bodies stall, instead of
overrunning stacked phase budgets.

Evidence

  • Changed: scripts/e2e/lib/plugins/assertions.mjs,
    test/scripts/plugins-assertions.test.ts
  • Production caller path: plugins E2E clawhub-preflight →
    assertClawHubPreflight → one withTimeout(…, limits.timeoutMs, …) covering
    fetch + readBoundedResponseText(…, timeoutPromise) + JSON.parse
  • Compatibility: same env knobs
    (OPENCLAW_PLUGINS_E2E_CLAWHUB_PREFLIGHT_TIMEOUT_MS,
    OPENCLAW_PLUGINS_E2E_CLAWHUB_PREFLIGHT_BODY_MAX_BYTES); only the deadline
    model changes from phase-stacked to shared total

Real behavior proof

Behavior or issue addressed

Against a live loopback ClawHub package-metadata endpoint that delays headers
then never finishes the JSON body, production clawhub-preflight fails within
one shared timeoutMs budget. A completing metadata response still parses and
prints the package family on the same path.

Canonical reachability path

node scripts/e2e/lib/plugins/assertions.mjs clawhub-preflight →
assertClawHubPreflight (scripts/e2e/lib/plugins/assertions.mjs) →
withTimeout("ClawHub package preflight for …", limits.timeoutMs, …) →
fetch(preflightUrl, { signal }) →
readBoundedResponseText(…, timeoutPromise) → JSON.parse(rawDetail)

Shared helper / provider constraint check

Reuses existing withTimeout + readBoundedResponseText; no new timeout env
surface. The outer timeoutPromise is forwarded into the body reader so the
shared deadline covers headers and body together.

Real environment tested

Real HTTP transport: local node:http ClawHub stand-in on 127.0.0.1 serving
/api/v1/packages/%40openclaw%2Fkitchen-sink.

  1. Stalled: delay headers 1000ms, write a partial JSON chunk, never end —
    drive production assertions.mjs clawhub-preflight with
    OPENCLAW_PLUGINS_E2E_CLAWHUB_PREFLIGHT_TIMEOUT_MS=1500.
  2. Completing: return a full code-plugin package JSON on the same path
    with timeoutMs=5000.

Node v22.23.1, PR head f664f7f640c9a83d65af4ca7c1ff5720e12af7d8.

Exact steps or command run after this patch

Production entrypoint driven against a live loopback ClawHub metadata server:

# Server A (stalled): delay headers 1000ms, write '{"package":', never end.
# Server B (complete): 200 + {"package":{"family":"code-plugin","runtimeId":"openclaw-kitchen-sink-fixture"}}
# For each server:
CLAWHUB_PLUGIN_ID=openclaw-kitchen-sink-fixture \
CLAWHUB_PLUGIN_SPEC='clawhub:@openclaw/kitchen-sink' \
OPENCLAW_CLAWHUB_URL="http://127.0.0.1:<port>" \
OPENCLAW_PLUGINS_E2E_CLAWHUB_PREFLIGHT_TIMEOUT_MS=<1500|5000> \
node scripts/e2e/lib/plugins/assertions.mjs clawhub-preflight

Supplemental focused regression on the same assertion helper:

node scripts/run-vitest.mjs test/scripts/plugins-assertions.test.ts -t "keeps ClawHub preflight wall time" --reporter=dot

Evidence after fix

proof root: /private/tmp/openclaw-pr-109045
assertions: /private/tmp/openclaw-pr-109045/scripts/e2e/lib/plugins/assertions.mjs
node: v22.23.1
head: f664f7f640c9a83d65af4ca7c1ff5720e12af7d8

=== stalled body under shared deadline ===
  ok: ceiling 2000ms is below stacked budget 2500ms
[stalled] loopback ClawHub at http://127.0.0.1:58205/api/v1/packages/%40openclaw%2Fkitchen-sink (headerDelay=1000ms, timeoutMs=1500)
  ok: stalled preflight exits non-zero — status=1
  ok: stalled preflight uses shared outer deadline — stderr contains: ClawHub package preflight for @openclaw/kitchen-sink timed out after 1500ms
  ok: stalled preflight stays within one shared budget — elapsed=1638ms < 2000ms (stacked would need >= 2500ms)
  detail: status=1 elapsed=1638ms stderr=… Error: ClawHub package preflight for @openclaw/kitchen-sink timed out after 1500ms … at assertClawHubPreflight (…/assertions.mjs:850:24) … code: 'ETIMEDOUT'

=== completing body under shared deadline ===
[complete] loopback ClawHub at http://127.0.0.1:58216/api/v1/packages/%40openclaw%2Fkitchen-sink (timeoutMs=5000)
  ok: completing preflight exits 0 — status=0
  ok: completing preflight parses family through shared deadline path
  detail: status=0 elapsed=155ms stdout="Using ClawHub package @openclaw/kitchen-sink (code-plugin)."

ALL PROOF ASSERTIONS PASSED

Observed result after fix

With headers delayed 1000ms and a stalled body, production clawhub-preflight
fails closed at ~1638ms under a 1500ms shared budget — below the 2000ms shared
ceiling and well under the old stacked allowance (≥2500ms =
headerDelay + timeoutMs). The error is the outer preflight timeout
(ETIMEDOUT from assertClawHubPreflight), not a second per-phase body
deadline. A completing metadata body still succeeds and prints the package
family.

What was not tested

Live stall against production https://clawhub.ai package metadata outside the
loopback harness.

Fix classification

bugfix — timeout/hang (E2E automation)

AI Assistance

AI-assisted. Author reviewed the shared-deadline wiring and the loopback
changed-path proof output for clawhub-preflight.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: S labels Jul 16, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 16, 2026
@clawsweeper

clawsweeper Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 18, 2026, 11:22 AM ET / 15:22 UTC.

Summary
The branch changes the plugins E2E ClawHub package-preflight assertion to use one timeout across metadata fetch, bounded response-body reading, and JSON parsing, with regression coverage for the shared wall-clock budget.

PR surface: Tests +48, Other -18. Total +30 across 2 files.

Reproducibility: yes. for the proposed branch: the supplied loopback scenario drives the real clawhub-preflight entrypoint through delayed headers and an unfinished body, then observes the shared deadline. Current-main reproduction was not independently run in this read-only review.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: serialized state: scripts/e2e/lib/plugins/assertions.mjs. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Refresh the branch against current main and confirm the focused E2E regression still passes on the reviewed head.

Risk before merge

  • [P1] Merging changes the failure timing and error source for a shared plugins E2E preflight assertion; refresh the branch against current main and retain the focused shared-budget regression before landing.

Maintainer options:

  1. Refresh and retain the bounded-preflight test (recommended)
    Rebase or refresh the branch against current main, then keep the loopback shared-wall-clock regression as the merge guard for this E2E assertion behavior.
  2. Accept the narrower E2E scope
    Merge only if maintainers accept that this fixes the E2E package-preflight deadline while the broader runtime request deadline remains owned by fix(clawhub): bound streaming metadata and error responses #109092.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Refresh the branch against current main and rerun the focused plugins-assertions regression before merging.

Next step before merge

  • [P2] No mechanical repair is identified; maintainer review should refresh the branch against current main and decide whether to land this distinct E2E-helper improvement alongside the related runtime timeout work.

Security
Cleared: The two-file E2E helper and test change adds no dependency, credential, permission, workflow, package-resolution, or artifact-execution surface.

Review details

Best possible solution:

Keep one total timeout budget in the E2E package-preflight helper, preserve the existing timeout environment variables, and land it after a current-base review confirms the helper remains separate from the runtime ClawHub timeout work.

Do we have a high-confidence way to reproduce the issue?

Yes for the proposed branch: the supplied loopback scenario drives the real clawhub-preflight entrypoint through delayed headers and an unfinished body, then observes the shared deadline. Current-main reproduction was not independently run in this read-only review.

Is this the best way to solve the issue?

Yes, with current-base confirmation: one outer deadline is the narrowest way to prevent phase-stacked timeouts in this E2E helper without adding configuration surface; the related runtime implementation remains a separate owner boundary.

AGENTS.md: unclear because the file could not be read completely.

Codex review notes: model internal, reasoning high; reviewed against faf3dbdda833.

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes changed-path terminal output from the production clawhub-preflight entrypoint using real loopback HTTP servers, showing both a bounded stalled-body failure and a successful complete response; no private values are exposed in the supplied output.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes changed-path terminal output from the production clawhub-preflight entrypoint using real loopback HTTP servers, showing both a bounded stalled-body failure and a successful complete response; no private values are exposed in the supplied output.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded reliability improvement to plugin E2E automation, with no demonstrated end-user runtime outage.
  • merge-risk: 🚨 automation: The diff changes the timeout model and expected error behavior of the plugins E2E preflight command, so an incorrect merge could alter automated validation timing.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes changed-path terminal output from the production clawhub-preflight entrypoint using real loopback HTTP servers, showing both a bounded stalled-body failure and a successful complete response; no private values are exposed in the supplied output.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes changed-path terminal output from the production clawhub-preflight entrypoint using real loopback HTTP servers, showing both a bounded stalled-body failure and a successful complete response; no private values are exposed in the supplied output.
Evidence reviewed

PR surface:

Tests +48, Other -18. Total +30 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 50 2 +48
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 14 32 -18
Total 2 64 34 +30

What I checked:

Likely related people:

What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (3 earlier review cycles)
  • reviewed 2026-07-16T14:00:50.179Z sha f664f7f :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T13:12:33.505Z sha f664f7f :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T13:54:21.726Z sha f664f7f :: needs real behavior proof before merge. :: none

@hugenshen

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 17, 2026
@hugenshen

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated the PR body with changed-path real behavior proof for production scripts/e2e/lib/plugins/assertions.mjs clawhub-preflight (loopback stalled body under one shared deadline + completing metadata parse). Replaced the earlier unrelated QA Lab Crabline proof.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 18, 2026
@steipete

Copy link
Copy Markdown
Contributor

Closing per ClawSweeper review verdict duplicate_or_superseded (decision packet 2026-07-18T16:05:04.948Z). This item was part of the audited close backlog (openclaw/clawsweeper#920) stranded by an apply-lane defect, drained manually after re-verification. If this is wrong, reopen and ClawSweeper will re-review.

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

Labels

merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants