Skip to content

fix(test): synchronize googlechat/feishu close assertions on events - #136768

Merged
steipete merged 1 commit into
openclaw:mainfrom
leilei3167:fix/test-close-sync-126905
Sep 27, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
leilei3167:fix/test-close-sync-126905

Conversation

@leilei3167

@leilei3167 leilei3167 commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #126905

What Problem This Solves

Google Chat media-download tests used fixed wall-clock waits (Promise.race with 100ms, and setTimeout(0)) to observe HTTP connection close and stream cancellation. Under a busy event loop the assertion can run before the close/cancel event is delivered even though cleanup still happens.

Feishu had the same class of flake; that path is already event-driven on main via #153277, so this PR no longer touches Feishu after rebase.

Why This Change Was Made

Rebased onto current main (172d054f5). Single-file, test-only change in extensions/googlechat/src/targets.test.ts:

  • Await responseClosedPromise (loopback server res.on("close")) instead of racing a 100ms timer after the size-limit rejection.
  • Await canceledPromise (ReadableStream cancel) instead of setTimeout(0) before asserting explicit byte-limit cancellation.

If close/cancel never arrives, vitest still times out — same failure mode, without timing races.

User Impact

No user-facing runtime change. CI gets more deterministic Google Chat media cleanup assertions.

Evidence

Box vitest (Node 24, node scripts/run-vitest.mjs):

$ node scripts/run-vitest.mjs extensions/googlechat/src/targets.test.ts
...
 ✓ downloadGoogleChatMedia > bounds chunked endpoint media downloads even when callers omit maxBytes 83ms
 ✓ downloadGoogleChatMedia > preserves stricter explicit media byte limits 2ms
...
 Test Files  1 passed (1)
      Tests  42 passed (42)
[test] passed 1 Vitest shard in 40.23s

Delayed-close / cancel synchronization (what the two cases exercise):

  1. Chunked loopback download — local createServer registers res.on("close") → responseClosedPromise. After downloadGoogleChatMedia rejects on the 20 MiB cap, the test await responseClosedPromise (no setTimeout). The passing run above shows the close event was observed before assertions (responseClosed === true, bytesSent < totalBytes).

  2. Explicit maxBytes stream — ReadableStream cancel() resolves canceledPromise. After the expected rejection, await canceledPromise replaces setTimeout(0); the run above completes with canceled === true without an arbitrary delay.

No live Google Chat or Feishu credentials; loopback HTTP only. No fabricated live-channel runs.

@clawsweeper

clawsweeper Bot commented Sep 3, 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 channel: googlechat Channel integration: googlechat channel: feishu Channel integration: feishu size: XS labels Sep 3, 2026
@leilei3167

Copy link
Copy Markdown
Contributor Author

Check-in: fresh focused test-only fix for #126905 on current main (does not reopen #126911).

Replaced wall-clock close waits with awaiting the existing close/cancel event promises in extensions/googlechat/src/targets.test.ts and extensions/feishu/src/media-chunk-idle.test.ts.

Local vitest: feishu media-chunk-idle 2/2, googlechat targets 42/42 via node scripts/run-vitest.mjs on those two files.

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Sep 3, 2026
@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 26, 2026, 9:45 PM ET / September 27, 2026, 01:45 UTC (Revision 5).

ClawSweeper review

What this changes

Changes two Google Chat media-download tests to await connection-close and stream-cancellation events before checking cleanup.

Merge readiness

⛔ Blocked before merge - 2 items remain

Current main still has both timing-dependent Google Chat assertions, and this focused patch addresses them. Feishu’s corresponding wait was merged separately. The remaining merge blocker is proof that this head succeeds when close delivery is delayed; its reported run covers ordinary timing.

Priority: P3
Reviewed head: 172d054f5f13ca9539b5545634c6aa3c9e0dd9ff

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and the ordinary loopback run passes, but proof of the timing failure it targets remains incomplete.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: The Node 24 terminal transcript shows ordinary after-change execution of the real Google Chat downloader with a loopback HTTP client, including passing cleanup assertions. It does not show delayed close delivery defeating the former timer race and succeeding with this head’s event wait. Add redacted before/after terminal evidence for that scenario; redact private endpoints and credentials. Updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. No stored-data contract changes. 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.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The Node 24 terminal transcript shows ordinary after-change execution of the real Google Chat downloader with a loopback HTTP client, including passing cleanup assertions. It does not show delayed close delivery defeating the former timer race and succeeding with this head’s event wait. Add redacted before/after terminal evidence for that scenario; redact private endpoints and credentials. Updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. No stored-data contract changes. 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.
Evidence reviewed 7 items Introduced patch: The pinned PR delta replaces the 100 ms race with the existing close promise and replaces a zero-delay timer with a cancellation promise; it changes no production file.
Current-main gap: Fetched main still races the close promise against 100 ms and waits one timer tick for cancellation, so the distinct Google Chat repair remains necessary.
Production boundary: The downloader passes its byte limit to the shared bounded response reader; the loopback case exercises this downloader with a real local HTTP server and fetch client.
Findings None None.
Security None None.

How this fits together

The Google Chat plugin downloads inbound media through a guarded request and enforces a byte limit before saving the attachment. These tests check that an oversized response stops the transfer and closes its transport.

flowchart LR
  A[Inbound media request] --> B[Google Chat downloader]
  B --> C[Byte limit decision]
  C --> D[Cancel response stream]
  D --> E[Connection close event]
  E --> F[Cleanup assertions]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The Node 24 terminal transcript shows ordinary after-change execution of the real Google Chat downloader with a loopback HTTP client, including passing cleanup assertions. It does not show delayed close delivery defeating the former timer race and succeeding with this head’s event wait. Add redacted before/after terminal evidence for that scenario; redact private endpoints and credentials. Updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. No stored-data contract changes. 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.
  • Complete next step (P2) - Add redacted before/after delayed-close terminal evidence through the Google Chat downloader and loopback transport before merge.
Agent review details

Security

None.

PR surface

Tests -2. Total -2 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 7 9 -2
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 7 9 -2

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #126905
Summary: The open issue describes the timing-dependent assertions; this PR is the candidate for its remaining Google Chat portion.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep the event-based assertions and establish their delayed-close red/green behavior through the downloader and loopback transport before landing.

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

Yes, from source: current main can finish the 100 ms race before observing connection close. The linked earlier PR reports a delayed-close red/green run, but this review did not execute one.

Is this the best way to solve the issue?

Yes. Awaiting the events already observed by these tests is a narrow repair that preserves their cleanup assertions.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 53af3ce10c37.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This repairs internal test reliability without changing user-facing runtime behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The Node 24 terminal transcript shows ordinary after-change execution of the real Google Chat downloader with a loopback HTTP client, including passing cleanup assertions. It does not show delayed close delivery defeating the former timer race and succeeding with this head’s event wait. Add redacted before/after terminal evidence for that scenario; redact private endpoints and credentials. Updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. No stored-data contract changes. 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.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • sunlit-deng: 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 redacted before/after terminal evidence that delays close delivery beyond the former deadline through the downloader and shows the event-based assertion succeeding.

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.

History

Review history (4 earlier review cycles)
  • reviewed 2026-09-03T00:48:10.868Z sha c81e50eba9b55159041a3c6e5374ac125f5b266f :: needs maintainer review before merge. :: none
  • reviewed 2026-09-07T03:40:45.276Z sha efc08bf07a9f0fca95210db8f86274368daefc26 :: needs real behavior proof before merge. :: none
  • reviewed September 22, 2026, 6:45 PM ET / 22:45 UTC (Revision 3) sha unknown :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-23T02:22:07.830Z sha 172d054 :: needs real behavior proof before merge. :: none

@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label Sep 7, 2026
@github-actions github-actions Bot removed the dependencies-changed PR changes dependency-related files label Sep 7, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed 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. labels Sep 7, 2026
@leilei3167

Copy link
Copy Markdown
Contributor Author

Hi — just a friendly ping on this PR whenever you have a moment. Could someone with merge rights take a look when convenient? Happy to address any feedback. Thanks!

Rebase onto current main: drop the Feishu hunk (main already has the
socket-close wait from openclaw#153277) and keep the Google Chat timing fixes.

- await responseClosedPromise instead of racing a 100ms timer
- await stream cancel via canceledPromise instead of setTimeout(0)
@leilei3167
leilei3167 force-pushed the fix/test-close-sync-126905 branch from efc08bf to 172d054 Compare September 23, 2026 02:13
@leilei3167

Copy link
Copy Markdown
Contributor Author

Rebased onto current main and dropped the Feishu file — that wait is already on main via #153277.

This tip only touches extensions/googlechat/src/targets.test.ts: await the loopback close promise and the stream cancel promise instead of the old 100ms / zero-delay timers. Updated the PR description with the vitest transcript for the two cleanup cases.

Head: 172d054f5f13ca9539b5545634c6aa3c9e0dd9ff. Happy to adjust if you want a different proof format.

@openclaw-barnacle openclaw-barnacle Bot removed the channel: feishu Channel integration: feishu label Sep 23, 2026
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit 23ad3a5 into openclaw:main Sep 27, 2026
101 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 27, 2026
…nclaw#136768)

Rebase onto current main: drop the Feishu hunk (main already has the
socket-close wait from openclaw#153277) and keep the Google Chat timing fixes.

- await responseClosedPromise instead of racing a 100ms timer
- await stream cancel via canceledPromise instead of setTimeout(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: googlechat Channel integration: googlechat P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

googlechat/feishu tests synchronize close assertions on wall-clock windows

2 participants