Skip to content

fix(gateway): catch lazy import rejections in runtime event subscriptions#100401

Merged
steipete merged 3 commits into
openclaw:mainfrom
cxbAsDev:fix/gateway-runtime-subscriptions-catch
Jul 6, 2026
Merged

fix(gateway): catch lazy import rejections in runtime event subscriptions#100401
steipete merged 3 commits into
openclaw:mainfrom
cxbAsDev:fix/gateway-runtime-subscriptions-catch

Conversation

@cxbAsDev

@cxbAsDev cxbAsDev commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Gateway runtime subscriptions deliberately fire three lazy event handlers without awaiting them. On current main, a rejected module load, handler construction, synchronous handler call, or returned promise can escape that fire-and-forget boundary as an unhandled rejection.

Why This Change Was Made

The final implementation keeps event delivery asynchronous but routes agent, transcript, and lifecycle dispatch through one local helper that owns the rejection boundary. Failures are logged with the relevant run or session identifiers. The existing Gateway subsystem logger is passed from the only production caller.

The maintainer fixup also corrects the original warning semantics: the catch covers handler execution as well as lazy loading, so the log reports a dispatch failure rather than claiming every failure came from an import. Typed test parameters repair the original check-test-types failure.

User Impact

Transient Gateway event-handler failures no longer surface as unexplained process-level unhandled rejections. Operators get an actionable warning while unrelated Gateway subscriptions continue running.

Evidence

AI assistance: Codex performed maintainer review, implementation cleanup, focused proof selection, and landing preparation.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Jul 5, 2026
@clawsweeper

clawsweeper Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 5, 2026, 8:48 PM ET / 00:48 UTC.

Summary
Adds a Gateway runtime subscription helper that catches and logs lazy event-handler failures, passes the Gateway logger from startup, adds regression tests, and edits CHANGELOG.md.

PR surface: Source +36, Tests +120, Docs +1. Total +157 across 4 files.

Reproducibility: yes. Current main source shows three fire-and-forget lazy event dispatches without catch handlers, and the PR tests exercise the rejected module and handler failure paths.

Review metrics: 1 noteworthy metric.

  • Release-owned files changed: 1 changed. CHANGELOG.md is owned by release generation, so this otherwise narrow Gateway fix has one process-sensitive edit to remove.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

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

Rank-up moves:

  • Remove the CHANGELOG.md entry; the PR body already has release-note context.
  • [P1] Add redacted live/log proof of a Gateway lazy subscriber failure being contained, or get an explicit proof override.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR supplies regression tests, CI, and maintainer validation notes, but no redacted live Gateway fault-injection logs or terminal output; add real behavior proof and redact IPs, keys, phone numbers, and private endpoints before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] Real behavior proof is still mock/CI-only; no redacted live Gateway fault-injection transcript or logs show the process-level rejection containment after the fix.
  • [P1] The manual CHANGELOG.md entry conflicts with the release-owned changelog workflow and should be removed before merge.

Maintainer options:

  1. Decide the mitigation before merge
    Land the runtime and regression-test fix after removing the changelog line and adding redacted live/log proof or an explicit proof override.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] Human/contributor follow-up is needed because proof is mock/CI-only and the changelog edit must be removed; ClawSweeper should not queue repair while the proof gate is unsatisfied.

Security
Cleared: The diff only changes local Gateway rejection handling, tests, and a changelog line; it does not alter dependencies, workflows, secrets, permissions, packaging, or executable supply-chain inputs.

Review findings

  • [P3] Remove the release-owned changelog edit — CHANGELOG.md:22
Review details

Best possible solution:

Land the runtime and regression-test fix after removing the changelog line and adding redacted live/log proof or an explicit proof override.

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

Yes. Current main source shows three fire-and-forget lazy event dispatches without catch handlers, and the PR tests exercise the rejected module and handler failure paths.

Is this the best way to solve the issue?

Yes for the runtime code: catching at the subscription-owned fire-and-forget boundary is the narrow maintainable fix. The changelog edit is not part of the best solution and should be removed.

Full review comments:

  • [P3] Remove the release-owned changelog edit — CHANGELOG.md:22
    Root AGENTS.md says CHANGELOG.md is release-only and normal PRs should put release-note context in the PR body or squash message. This PR already has release-note context in the body, so keeping this manual entry creates release-generation churn; this re-raises the prior ClawSweeper finding on the current head.
    Confidence: 0.96

Overall correctness: patch is correct
Overall confidence: 0.86

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: This is a focused Gateway availability fix for unhandled promise rejections with limited blast radius and no release-blocker evidence.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
Evidence reviewed

PR surface:

Source +36, Tests +120, Docs +1. Total +157 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 39 3 +36
Tests 1 120 0 +120
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 160 3 +157

What I checked:

Likely related people:

  • Vincent Koc: Blame on the current Gateway runtime subscription file and lazy handler call sites points to the commit that introduced the current source shape. (role: introduced current-main behavior; confidence: high; commits: aa665817490b; files: src/gateway/server-runtime-subscriptions.ts, src/gateway/server-chat.ts, src/gateway/server-session-events.ts)
  • steipete: He is assigned on this PR, authored the consolidation/changelog commits on the PR branch, and posted the land-ready maintainer pass. (role: recent PR reviewer and likely follow-up owner; confidence: high; commits: 00e5c550e757, 007793be877c, 95f12178a794; files: src/gateway/server-runtime-subscriptions.ts, src/gateway/server-runtime-subscriptions.test.ts, CHANGELOG.md)
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 (2 earlier review cycles)
  • reviewed 2026-07-05T18:08:08.595Z sha dd37138 :: needs real behavior proof before merge. :: [P2] Use typed gateway test maps
  • reviewed 2026-07-06T00:33:25.447Z sha b516390 :: needs real behavior proof before merge. :: [P3] Remove the release-owned changelog edit

@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. labels Jul 5, 2026
@steipete steipete self-assigned this Jul 5, 2026
@steipete
steipete force-pushed the fix/gateway-runtime-subscriptions-catch branch 2 times, most recently from cecb4e1 to 7ca2bba Compare July 6, 2026 00:02
@clawsweeper clawsweeper Bot 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 6, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: ios App: ios scripts Repository scripts size: XL and removed size: S labels Jul 6, 2026
@steipete
steipete force-pushed the fix/gateway-runtime-subscriptions-catch branch from 51fc6f5 to b516390 Compare July 6, 2026 00:14
@openclaw-barnacle openclaw-barnacle Bot added size: S and removed docs Improvements or additions to documentation app: ios App: ios scripts Repository scripts size: XL labels Jul 6, 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. labels Jul 6, 2026
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Land-ready maintainer pass complete.

Known proof gap: no manual live Gateway fault injection was added beyond the deterministic module/handler regression tests. The failure boundary itself is exercised directly.

@clawsweeper clawsweeper Bot removed the rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. label Jul 6, 2026
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Jul 6, 2026
@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord channel: slack Channel integration: slack channel: telegram Channel integration: telegram scripts Repository scripts agents Agent runtime and tooling labels Jul 6, 2026
@clawsweeper clawsweeper Bot removed the status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. label Jul 6, 2026
@steipete
steipete force-pushed the fix/gateway-runtime-subscriptions-catch branch from 4cbb940 to 007793b Compare July 6, 2026 00:41
@openclaw-barnacle openclaw-barnacle Bot added size: S and removed docs Improvements or additions to documentation channel: discord Channel integration: discord channel: slack Channel integration: slack channel: telegram Channel integration: telegram scripts Repository scripts agents Agent runtime and tooling size: XL labels Jul 6, 2026
@steipete
steipete merged commit 5a31666 into openclaw:main Jul 6, 2026
119 of 122 checks passed
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 6, 2026
…ions (openclaw#100401)

* fix(gateway): catch lazy import rejections in runtime event subscriptions

* fix(gateway): consolidate event dispatch failures

* docs(changelog): note gateway event dispatch fix

---------

Co-authored-by: Peter Steinberger <[email protected]>
giodl73-repo pushed a commit to giodl73-repo/openclaw that referenced this pull request Jul 8, 2026
…ions (openclaw#100401)

* fix(gateway): catch lazy import rejections in runtime event subscriptions

* fix(gateway): consolidate event dispatch failures

* docs(changelog): note gateway event dispatch fix

---------

Co-authored-by: Peter Steinberger <[email protected]>
@cxbAsDev
cxbAsDev deleted the fix/gateway-runtime-subscriptions-catch branch July 15, 2026 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants