Skip to content

fix(discord): clear pending launch watchdog - #115100

Merged
steipete merged 3 commits into
openclaw:mainfrom
IWhatsskill:agent/fix-discord-activity-write-timer
Jul 28, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
IWhatsskill:agent/fix-discord-activity-write-timer

Conversation

@IWhatsskill

@IWhatsskill IWhatsskill commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

[AI-assisted]

What Problem This Solves

A successful Discord Activity pending-launch write normally completes well inside its 250 ms safety budget, but the losing watchdog timer remained armed until the full deadline. Bursts of otherwise healthy button clicks therefore retained unnecessary timer resources and their closures after the store work was already complete.

Failure mode

The store promise won the race, the Activity launched, and the unreachable timeout promise stayed scheduled for the rest of its budget because its handle existed only inside the promise constructor.

Why This Change Was Made

The interaction retains the per-invocation watchdog handle and clears it in a finally block as soon as the write-versus-timeout race settles. The same cleanup runs after a real timeout, while the caught store promise remains alive so a late write can still finish safely.

Root Cause

The watchdog handle was scoped inside the timeout promise, so the owner awaiting Promise.race had no way to dispose of the losing timer.

Runtime ownership

DiscordActivityButton.run owns the bounded wait and its per-invocation native timer. DiscordActivityStore continues to own pending-launch identity, ambiguity, consumption, retirement, and TTL semantics; the HTTP handler continues to own explicit, pending, and newest-widget resolution.

User Impact

Healthy Discord Activity launches release their no-longer-needed watchdog immediately. The 250 ms acknowledgement budget, launch ordering, single diagnostic on failure, invalid-widget response, late background write behavior, and pending-launch HTTP resolution remain unchanged.

Evidence

Validated at exact head 1d0ff09793f08fa7c897ac3b244c366db4f20aef: a non-mocked production-module runtime observed the native 250 ms watchdog destroyed after 0.62 ms without executing; 41/41 focused Discord Activity tests also passed.

Inspect exact-head proof ledger

Provenance

  • Base: 89b6d85cdd862d3315927abcc604c9e128e67314
  • Proof head: 1d0ff09793f08fa7c897ac3b244c366db4f20aef
  • Revalidated: after merging current upstream main

Direct behavior

  • Native Node runtime observation (MEASURED) — Observed: the production DiscordActivityButton.run and DiscordActivityStore path used unmodified Node timer APIs with no test runner or fake timers; async_hooks observed exactly one native 250 ms watchdog, destroyed after 0.62 ms, and its callback never executed during the 300 ms observation window. Result: the pending launch was visible, Activity launch ran once, and no error was logged. Proves a successful real store write clears the losing native watchdog before its deadline instead of leaving the callback armed. Preserves pending-launch visibility, Activity launch ordering, the 250 ms deadline, and the zero-error healthy path.

Redacted exact-head terminal output

$ git rev-parse HEAD
1d0ff09793f08fa7c897ac3b244c366db4f20aef

$ <isolated Node runtime invocation of production DiscordActivityButton.run and DiscordActivityStore>
{
  "exact_head": "1d0ff09793f08fa7c897ac3b244c366db4f20aef",
  "runtime_path": "production DiscordActivityButton.run + DiscordActivityStore",
  "test_runner": "none",
  "fake_timers": false,
  "timer_api_unmodified": true,
  "watchdog_async_id": 55,
  "watchdog_deadline_ms": 250,
  "watchdog_lifetime_ms": 0.62,
  "watchdog_destroyed_before_deadline": true,
  "watchdog_callback_executed": false,
  "button_run_elapsed_ms": 0.56,
  "pending_launch_visible_before_activity_query": true,
  "launch_count": 1,
  "error_count": 0
}

Automated verification

Discord Activity runtime contract

node scripts/run-vitest.mjs extensions/discord/src/activities/interaction.test.ts extensions/discord/src/activities/http.test.ts --run --reporter=verbose
  • node scripts/run-vitest.mjs extensions/discord/src/activities/interaction.test.ts extensions/discord/src/activities/http.test.ts --run --reporter=verbose — 2 test files and 41 tests passed with 0 failures and 0 skips. Proves the button and HTTP paths remain correct across fast success, timeout, late settlement, rejection, invalid widget data, pending-launch consumption, overlap, account isolation, and lookup failure. Preserves the 250 ms acknowledgement budget, launch ordering, newest-widget fallback, keyed store semantics, and HTTP authorization and channel validation.

Focused static verification

git diff --check origin/main...HEAD
  • git diff --check origin/main...HEAD — completed with exit code 0 and no output. Proves the current Base-to-HEAD patch has no whitespace errors. Preserves the exact reviewed two-file manifest.

Preserved boundaries

  • The pending-launch write still uses the same nominal 250 ms watchdog; event-loop scheduling may make observed elapsed time slightly longer.
  • A timed-out write remains observed and may complete in the background; it is not cancelled.
  • The keyed store's two-minute TTL, same-widget idempotence, different-widget ambiguity, consume and retire behavior, account isolation, and newest-widget fallback are unchanged.
  • No Discord authentication, authorization, network callback, rendering, or configuration contract changes.

Proof gap

A credentialed live Discord interaction was not run because the proof environment does not use live Discord credentials. The non-mocked production button and store modules ran with unmodified native Node timers, and async_hooks observed the watchdog lifecycle without replacing the timer APIs. No external Discord delivery or persistent backend performance claim is made.

Artifacts

  • A redacted exact-head terminal transcript excerpt is embedded under Direct behavior; no separate binary artifact is attached.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord size: S labels Jul 28, 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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 28, 2026
@clawsweeper

clawsweeper Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 28, 2026, 8:05 AM ET / 12:05 UTC.

ClawSweeper review

What this changes

The PR keeps the per-click Discord Activity pending-launch watchdog handle and clears it after the pending-launch write race settles, with a regression test for successful writes.

Merge readiness

✅ Ready for maintainer review

Keep open. This is a focused Discord Activity resource-cleanup fix; the retained watchdog is cleared on both race outcomes, and the updated PR body now includes direct exact-head terminal evidence for the successful-write path.

Priority: P3
Reviewed head: 1d0ff09793f08fa7c897ac3b244c366db4f20aef

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused patch with direct after-fix runtime evidence and targeted regression coverage; no concrete correctness or security blocker was found.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body includes redacted exact-head terminal output from a non-test-runner execution through the production button and store modules, directly observing the native watchdog destroyed before its deadline; no live Discord credential claim is needed for this local timer behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body includes redacted exact-head terminal output from a non-test-runner execution through the production button and store modules, directly observing the native watchdog destroyed before its deadline; no live Discord credential claim is needed for this local timer behavior.
Evidence reviewed 4 items Race cleanup is scoped to the owning button invocation: The PR retains the timeout handle outside the promise executor and clears it in a finally block after Promise.race settles, leaving the existing timeout budget and late-write behavior intact.
Regression coverage exercises the successful-write path: The added test captures the exact 250 ms watchdog handle, verifies clearTimeout receives it, waits past the original deadline, and confirms the callback did not run while the Activity still launches once.
After-fix runtime proof is present: The PR body records an exact-head, non-test-runner Node execution through the production button and store modules; its async-hooks observation reports the native watchdog destroyed before the 250 ms deadline without executing.
Findings None None.
Security None None.

How this fits together

A Discord Activity button records a pending launch before asking Discord to launch the Activity. That record is bounded by a 250 ms watchdog so a slow store operation cannot delay the interaction; the patch releases the timer once that bounded wait has resolved.

flowchart LR
  A[Discord Activity button click] --> B[Pending-launch store write]
  B --> C[250 ms watchdog]
  C --> D[Write-versus-timeout decision]
  D --> E[Clear watchdog handle]
  E --> F[Launch Discord Activity]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +7, Tests +63. Total +70 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 12 5 +7
Tests 1 64 1 +63
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 76 6 +70

Review metrics

None.

Technical review

Best possible solution:

Keep the timer cleanup and regression test as written, then land it through the normal required-check gate once the current head remains green.

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

Yes. The current-base implementation leaves the 250 ms watchdog handle inaccessible after the write wins, and the PR supplies an exact-head production-module terminal observation showing the corrected lifecycle.

Is this the best way to solve the issue?

Yes. Clearing the timer in the owner of the race is the narrowest maintainable fix; it preserves the store's ownership, timeout budget, late-write handling, and Activity launch ordering.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes redacted exact-head terminal output from a non-test-runner execution through the production button and store modules, directly observing the native watchdog destroyed before its deadline; no live Discord credential claim is needed for this local timer behavior.
  • 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 (terminal): The PR body includes redacted exact-head terminal output from a non-test-runner execution through the production button and store modules, directly observing the native watchdog destroyed before its deadline; no live Discord credential claim is needed for this local timer behavior.
  • remove rating: 🦪 silver shellfish: 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:

  • P3: This is a small internal Discord Activity timer-resource cleanup with no indicated change to delivery, authorization, configuration, or user-visible behavior.
  • 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 (terminal): The PR body includes redacted exact-head terminal output from a non-test-runner execution through the production button and store modules, directly observing the native watchdog destroyed before its deadline; no live Discord credential claim is needed for this local timer behavior.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes redacted exact-head terminal output from a non-test-runner execution through the production button and store modules, directly observing the native watchdog destroyed before its deadline; no live Discord credential claim is needed for this local timer behavior.

Evidence

What I checked:

  • Race cleanup is scoped to the owning button invocation: The PR retains the timeout handle outside the promise executor and clears it in a finally block after Promise.race settles, leaving the existing timeout budget and late-write behavior intact. (extensions/discord/src/activities/interaction.ts:72, 1d0ff09793f0)
  • Regression coverage exercises the successful-write path: The added test captures the exact 250 ms watchdog handle, verifies clearTimeout receives it, waits past the original deadline, and confirms the callback did not run while the Activity still launches once. (extensions/discord/src/activities/interaction.test.ts:142, 1d0ff09793f0)
  • After-fix runtime proof is present: The PR body records an exact-head, non-test-runner Node execution through the production button and store modules; its async-hooks observation reports the native watchdog destroyed before the 250 ms deadline without executing. (1d0ff09793f0)
  • Focused automated validation is reported: The PR body reports 41 passing focused Discord Activity tests covering the button and HTTP paths; repository checks shown in the review context include completed channel-boundary, type, guard, and security checks, with broader jobs still running. (extensions/discord/src/activities/interaction.test.ts:139, 1d0ff09793f0)

Likely related people:

  • steipete: The available review context does not expose usable file-history output; this is a bounded bundled Discord-plugin change, so repository-level Discord/plugin routing is the strongest available ownership signal rather than attributing ownership to the external PR author alone. (role: likely repository-level follow-up owner; confidence: low; files: extensions/discord/src/activities/interaction.ts, extensions/discord/src/activities/interaction.test.ts)

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 (5 earlier review cycles)
  • reviewed 2026-07-28T09:06:32.376Z sha 0920e4a :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-28T10:14:59.008Z sha 0920e4a :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-28T10:52:44.488Z sha e094871 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-28T11:15:32.396Z sha e094871 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-28T11:52:16.672Z sha e094871 :: needs real behavior proof before merge. :: none

@IWhatsskill
IWhatsskill marked this pull request as ready for review July 28, 2026 10:10
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 28, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jul 28, 2026
@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: 🦪 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 28, 2026
@steipete
steipete merged commit d22565c into openclaw:main Jul 28, 2026
97 of 106 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

vincentkoc added a commit that referenced this pull request Jul 28, 2026
…etwork-none

* origin/main: (24 commits)
  refactor(sessions): isolate legacy transcript fixtures (#115231)
  fix(discord): clear pending launch watchdog (#115100)
  fix(agents): stop quadratic subagent prompt rendering (#115263)
  fix(memory-core): recover dreaming cron reconciliation (#115174)
  fix(qa-lab): filter incompatible channel scenarios (#115087)
  fix(android): respect locale in compact labels
  test(i18n): prove iOS discovery catalog ownership
  chore(i18n): refresh gateway discovery catalogs
  fix(i18n): include shared discovery copy in macOS catalog
  fix(apple): localize gateway discovery status
  chore(i18n): drop release-owned changelog entry
  fix(macos): localize privacy permission prompts
  fix(voice-call): bracket IPv6 webhook hosts (#115135)
  test(ci): split control UI scope coverage
  fix(ui): detect composed accessibility copy
  fix(ci): run localization checks for UI changes
  test(ui): catch untranslated accessibility labels
  fix(ui): localize chat action labels
  fix(ui): localize chat status indicators
  fix(ui): sync document locale metadata
  ...
vincentkoc added a commit that referenced this pull request Jul 28, 2026
…-20260728

* origin/main: (21 commits)
  refactor(sessions): isolate legacy transcript fixtures (#115231)
  fix(discord): clear pending launch watchdog (#115100)
  fix(agents): stop quadratic subagent prompt rendering (#115263)
  fix(memory-core): recover dreaming cron reconciliation (#115174)
  fix(qa-lab): filter incompatible channel scenarios (#115087)
  fix(android): respect locale in compact labels
  test(i18n): prove iOS discovery catalog ownership
  chore(i18n): refresh gateway discovery catalogs
  fix(i18n): include shared discovery copy in macOS catalog
  fix(apple): localize gateway discovery status
  chore(i18n): drop release-owned changelog entry
  fix(macos): localize privacy permission prompts
  fix(voice-call): bracket IPv6 webhook hosts (#115135)
  test(ci): split control UI scope coverage
  fix(ui): detect composed accessibility copy
  fix(ci): run localization checks for UI changes
  test(ui): catch untranslated accessibility labels
  fix(ui): localize chat action labels
  fix(ui): localize chat status indicators
  fix(ui): sync document locale metadata
  ...
vincentkoc added a commit to LZY3538/openclaw that referenced this pull request Jul 28, 2026
* origin/main: (199 commits)
  refactor(workboard): tidy Control UI card execution helpers (openclaw#115195)
  perf(agents): amortize history-limit eviction with hysteresis (openclaw#115273) (openclaw#115281)
  fix: schema-version refusal blames a downgrade that never happened and cannot identify the stale install (openclaw#115232)
  fix: restore Fish completion after global CLI options (openclaw#115222)
  refactor(agents): collapse the client-tool catalog branch (openclaw#115212)
  fix(macos): signed rebuild no longer stalls on app shutdown (openclaw#103957)
  fix(agents): prevent repeated Code Mode output across waits (openclaw#115213)
  refactor(ui): split Profile (identity) from Usage (statistics) (openclaw#115245)
  fix(channels): report a channel that cannot receive as unhealthy instead of connected (openclaw#115229)
  fix(cli): reject malformed infer model refs (openclaw#115225)
  feat(ui): finish the Lobsterdex at 42 with wild variants, squish fix, and blink variance (openclaw#115264)
  test(migrations): avoid mtime precision in checkpoint fixture (openclaw#115269)
  test(signal): verify archive limits without malformed tar (openclaw#115270)
  refactor(sessions): isolate legacy transcript fixtures (openclaw#115231)
  fix(discord): clear pending launch watchdog (openclaw#115100)
  fix(agents): stop quadratic subagent prompt rendering (openclaw#115263)
  fix(memory-core): recover dreaming cron reconciliation (openclaw#115174)
  fix(qa-lab): filter incompatible channel scenarios (openclaw#115087)
  fix(android): respect locale in compact labels
  test(i18n): prove iOS discovery catalog ownership
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord 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. 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