Skip to content

fix(test): avoid unhandled catalog startup rejection - #158440

Merged
vincentkoc merged 1 commit into
mainfrom
fix-gateway-fixture-lifetimes-20260926
Sep 26, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix-gateway-fixture-lifetimes-20260926

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes an unhandled rejection in the cold Gateway catalog startup test, which could fail validation even when all three test cases passed.

User Impact

No runtime behavior changes. The fixture still verifies synchronous metadata capture and startup with provider settings without model rows.

Why This Change Was Made

The fixture rejected a deferred promise before startup had attached to it through an asynchronous module import. Resolve a void gate instead, then throw the same sentinel from the awaited bootstrap mock. Keep the metadata assertions before any await and preserve cleanup and exact error-identity checks.

Evidence

  • Cold baseline: all three catalog cases passed, but Vitest recorded the expected unhandled fixture stops bootstrap rejection and exited 1.
  • Cold candidate at unchanged 44f11c565956954260042108a5e6f77a4c8ab837: the same single-file command passed all three cases, exited 0, and had no unhandled rejection or late-handler warning. Node 24.21.0 / pnpm 12.4.2, one worker; source pins matched before and after. The delegated worker joined and stopped.
  • The catalog and existing metadata-close suites also passed all 9 cases in metadata-close-first order. Targeted formatting, lint, and the selected gateway-server test-type graph passed.
  • Exact-head hosted CI and required status contexts passed. Independent source review found no actionable code findings.

The cold candidate run addresses the review's cold-first proof and timing request without changing the head. Both cold commands were pnpm test src/gateway/server.catalog-startup.test.ts with CI=1 OPENCLAW_VITEST_MAX_WORKERS=1.

Cold run Vitest duration Native test wrapper Result
Baseline 68.58 s 70.52 s 3 assertions passed; unhandled rejection; exit 1
Candidate 64.50 s 66.70 s 3 cases passed; exit 0

The candidate command measured 67.081 s end to end. Its native delegated run reported 238.919 s total including setup; execution record. The external lease owner stops the worker after completion, so the backing workflow can show cancellation; the joined native result was exit 0. These single observations establish test cost and the repaired failure mode, not a speedup or tail-latency claim.

@vincentkoc vincentkoc self-assigned this Sep 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Sep 25, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review September 25, 2026 23:42
@clawsweeper

clawsweeper Bot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 25, 2026, 7:55 PM ET / 23:55 UTC.

ClawSweeper review

What this changes

The branch changes the Gateway catalog startup test to release a pause successfully and throw its existing fixture error from the awaited bootstrap mock.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open. Current main still has the rejection-prone test fixture, and the PR fixes its promise handling without changing Gateway runtime behavior. No introduced correctness or security defect was found.

Priority: P2
Reviewed head: 44f11c565956954260042108a5e6f77a4c8ab837

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused patch addresses the source-level race and reports passing candidate tests, with benchmark timing still to document.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This member-authored PR changes only a test fixture, so contributor runtime proof is not required. Its body reports the cold baseline failure and candidate test results; the scoped before/after benchmark remains undocumented. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored PR changes only a test fixture, so contributor runtime proof is not required. Its body reports the cold baseline failure and candidate test results; the scoped before/after benchmark remains undocumented. No stored-data contract changes.
Evidence reviewed 8 items Introduced patch: The PR resolves a void gate and throws the same sentinel inside the awaited bootstrap mock; the test still checks error identity and restores its mocks.
Current main still needs the fix: The fetched main revision still rejects the deferred promise directly in the test's finally block.
Startup ordering: The Gateway captures the catalog snapshot before awaiting an asynchronous import and then the bootstrap call, supporting the reported interval before the mock receives the promise.
Findings None None.
Security None None.

How this fits together

Gateway startup captures a model catalog snapshot before asynchronous bootstrap work. This test pauses bootstrap to check that the captured provider and pricing data stays stable, then checks how startup fails.

flowchart LR
  A[Stored model catalog] --> B[Gateway startup snapshot]
  B --> C[Paused bootstrap]
  C --> D[Provider and price checks]
  D --> E[Startup error settles]
Loading

Before merge

  • Resolve merge risk (P1) - The PR reports test outcomes but omits the before/after test-file wall times required by the scoped Gateway policy.
  • Complete next step (P2) - Record before/after wall times for the affected Gateway test file in the PR evidence.
Agent review details

Security

None.

PR surface

Tests +1. Total +1 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 5 4 +1
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 5 4 +1

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain a deterministic startup-boundary test that checks catalog snapshot timing, exact failure identity, clean promise settlement, and its measured test cost.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain a deterministic startup-boundary test that checks catalog snapshot timing, exact failure identity, clean promise settlement, and its measured test cost.

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

Yes, as a source-level path: current main can reject the gate before asynchronous startup reaches the mocked bootstrap call, and the PR reports a cold Vitest failure. I did not execute the test in this read-only review.

Is this the best way to solve the issue?

Yes. Throwing from the awaited mock preserves the original startup assertions and exact error check while removing the early rejected promise.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: An unhandled rejection can fail Gateway test validation despite passing cases, with impact limited to the test fixture.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: An unhandled rejection can fail Gateway test validation despite passing cases, with impact limited to the test fixture.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

  • Introduced patch: The PR resolves a void gate and throws the same sentinel inside the awaited bootstrap mock; the test still checks error identity and restores its mocks. (src/gateway/server.catalog-startup.test.ts:40, 44f11c565956)
  • Current main still needs the fix: The fetched main revision still rejects the deferred promise directly in the test's finally block. (src/gateway/server.catalog-startup.test.ts:69, b74bd07a2fb0)
  • Startup ordering: The Gateway captures the catalog snapshot before awaiting an asynchronous import and then the bootstrap call, supporting the reported interval before the mock receives the promise. (src/gateway/server-kernel.ts:149, b74bd07a2fb0)
  • Deferred helper contract: The shared deferred helper defaults to void, so resolving the new gate without a value matches its type and purpose. (src/shared/deferred.ts:13, 44f11c565956)
  • Reported validation: The PR body reports a cold baseline with three passing cases but a Vitest unhandled rejection and exit 1, followed by nine passing candidate and sibling cases without that warning. It does not give before/after wall times.
  • Gateway benchmark policy: The applicable Gateway guide requires a before/after benchmark of the affected test file. (src/gateway/AGENTS.md:90, 44f11c565956)

Likely related people:

  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add before/after wall times for the affected Gateway test file to the PR evidence.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

@vincentkoc
vincentkoc merged commit f5f183d into main Sep 26, 2026
170 checks passed
@vincentkoc
vincentkoc deleted the fix-gateway-fixture-lifetimes-20260926 branch September 26, 2026 00:13
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 26, 2026
vincentkoc added a commit that referenced this pull request Sep 27, 2026
…#157940)

* fix(subagents): retain pending collector cleanup until Stop publishes

* fix(agents): settle accepted collector rollback after publication

* test(agents): keep collector fixtures within line caps

* fix(test): avoid unhandled catalog startup rejection (#158440)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 28, 2026
…openclaw#157940)

* fix(subagents): retain pending collector cleanup until Stop publishes

* fix(agents): settle accepted collector rollback after publication

* test(agents): keep collector fixtures within line caps

* fix(test): avoid unhandled catalog startup rejection (openclaw#158440)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant