Skip to content

fix(slack): prevent stalled presence polling from hanging shutdown - #117478

Merged
jalehman merged 3 commits into
openclaw:mainfrom
zhangguiping-xydt:fix/problem-slack-presence-poll-timeout
Aug 3, 2026
Merged

jalehman merged 3 commits into
openclaw:mainfrom
zhangguiping-xydt:fix/problem-slack-presence-poll-timeout

Conversation

@zhangguiping-xydt

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where Slack presence polling could freeze permanently when a users.getPresence request never returned. One stalled user prevented later users from being polled, and provider shutdown could remain blocked indefinitely.

Why This Change Was Made

Each presence lookup now has a 30-second monitor deadline and runs through a dedicated no-retry lookup client with a matching SDK transport timeout. The monitor stops the current batch on Slack rate limits and suppresses later polls through Retry-After. Provider teardown aborts the lookup client's in-flight fetch before waiting for the monitor, while the shared Bolt client remains timeout-free because it also carries mutation requests.

Root Cause and Design Boundary

Classification: root-cause fix. The presence monitor owns serial per-user progress and the task awaited by stop(), while the provider owns the Slack SDK transport lifecycle. Bounding only the outer promise would leave the socket alive; setting a timeout on the shared Bolt client would also change mutation behavior. The dedicated lookup client therefore applies real transport cancellation, and the monitor applies the same deadline to guarantee bounded task settlement.

The 30-second value is inherited from the existing canonical Slack read-client timeout in resolveSlackReadClientOptions: both paths are read-only Web API calls with the same stalled-transport failure semantics. It also remains below the 60-second presence polling cadence. Slack's server-provided Retry-After remains authoritative for rate limits; the fix adds no independent retry policy value.

Compatibility and scope: this changes no public API, config schema, protocol, token selection, authorization decision, or message/write retry behavior. The shared mutation-capable Bolt client, Enterprise Grid presence availability, presence eligibility, greeting, and cooldown behavior remain unchanged. A fresh broad open-PR scan found no semantically equivalent Slack presence deadline or shutdown fix; recalled timeout PRs were in unrelated owners and runtimes.

Merge risk is limited to Slack presence availability and provider cleanup. The dedicated client reuses the same token, proxy dispatcher, Slack API URL, and read timeout policy; focused tests and the real-SDK live proof cover continuity, rate limits, shutdown, and socket cleanup.

User Impact

Slack presence transitions continue polling after a stalled lookup, and stopping or restarting the Slack provider no longer waits forever on that request.

Evidence

Fresh origin/main at 1130f30445c4c5b5f242d2423061844e6f6e5949 still reproduced the bug before submission:

SOURCE presence_request_deadline=false shared_bolt_presence_client=true
TRIGGER latest_main_poll users=U0001,U0002 first_request=never_resolves
OUTCOME latest_main requests_started=1 later_user_polled=false poll_settled=false stop_settled=false
PASS problem_present=true

Near-real proof used the real @slack/web-api client against a loopback Slack HTTP API. The first scenario withheld response headers for U0001; the second aborted a stalled request at the provider shutdown boundary:

TRIGGER continuity_poll users=U0001,U0002
SLACK_API users.getPresence user=U0001 action=stall
[WARN] web-api:WebClient:0 http request failed The operation was aborted due to timeout
TRANSITION request_deadline user=U0001 timeout_ms=30000 poll_error_observed=true
TRANSITION stalled_socket user=U0001 socket_closed=true
SLACK_API users.getPresence user=U0002 action=respond presence=away
OUTCOME continuity elapsed_ms=29979 timeout_observed=true later_user_polled=true poll_settled=true
TRIGGER rate_limit_poll users=46 page_size=45 retry_after_s=120
SLACK_API users.getPresence user=U_RATE0001 action=rate_limit retry_after_s=120
TRANSITION retry_after_recorded retry_after_s=120 batch_stopped=true
SLACK_API users.getPresence user=U_RATE0001 action=respond presence=away
SLACK_API users.getPresence user=U_RATE0002 action=respond presence=away
SLACK_API users.getPresence user=U_RATE0046 action=respond presence=away
OUTCOME rate_limit observed=true batch_stopped=true requests_during_backoff=0 resumed_page_first=U_RATE0001 resumed_page_second=U_RATE0002 next_page_first=U_RATE0046 cursor_preserved=true
TRIGGER provider_presence_poll user=U_STOP
SLACK_API users.getPresence user=U_STOP action=stall
TRIGGER provider_stop request_in_flight=true gateway_budget_ms=5000
[WARN] web-api:WebClient:1 http request failed This operation was aborted
TRANSITION stalled_socket user=U_STOP socket_closed=true
OUTCOME provider_stop elapsed_ms=3 bounded_under_5000=true socket_closed=true
PASS provider_shutdown_settled=true
PASS no_open_sockets=true

Regression and repository checks:

  • presence-monitor.test.ts: 11 passed, including Retry-After batch and interval suppression
  • provider.auth-test-token.test.ts: 22 passed, including the real stalled-socket shutdown regression
  • oxfmt --check: 26,802 files matched

@openclaw-barnacle openclaw-barnacle Bot added channel: slack Channel integration: slack size: M labels Aug 1, 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. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 3, 2026, 4:43 AM ET / 08:43 UTC.

ClawSweeper review

What this changes

The branch gives Slack presence polling a dedicated timeout-bound lookup client, handles rate-limit backoff without losing the polling cursor, and aborts an in-flight lookup during provider shutdown.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this PR open for normal maintainer review. Current main still leaves a stalled Slack presence request inside the monitor’s active task, while this branch bounds the request, preserves polling progress across rate limits, and aborts the lookup transport before provider shutdown waits; the patch has no supported correctness finding.

Priority: P1
Reviewed head: 7365dbf61a31767af73aa479842b13299157e61b

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) The patch aligns timeout, SDK transport cancellation, rate-limit handling, and shutdown ownership with focused regression coverage and convincing real-client proof.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The PR body contains after-fix real @slack/web-api loopback output showing timeout continuity, Retry-After suppression and cursor preservation, plus provider-stop socket abort and bounded settlement; no sensitive values are exposed in the supplied transcript.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The PR body contains after-fix real @slack/web-api loopback output showing timeout continuity, Retry-After suppression and cursor preservation, plus provider-stop socket abort and bounded settlement; no sensitive values are exposed in the supplied transcript.
Evidence reviewed 6 items Current-main failure boundary: Current main serially awaits each users.getPresence call and its stop path awaits the active polling task; there is no request deadline or provider-owned cancellation path at that boundary, so a never-settling request can block later users and shutdown.
Root-cause repair on the PR head: The branch applies a 30-second monitor deadline, stops and records Retry-After rate limiting without consuming the failed cursor position, and advances the cursor only for settled non-rate-limited attempts.
Transport lifecycle ownership: The branch creates a no-retry lookup-only WebClient with the existing 30-second Slack read timeout and composes its fetch signal with a provider lifecycle AbortController; teardown aborts that controller before awaiting the monitor.
Findings None None.
Security None None.

How this fits together

The Slack plugin observes eligible conversation participants and periodically calls Slack’s presence API to emit away-to-active events. The provider owns the Slack SDK client lifecycle, while the presence monitor owns serial polling progress and the task that shutdown waits to settle.

flowchart LR
  A[Slack messages] --> B[Presence target registry]
  B --> C[Presence monitor]
  C --> D[Dedicated Slack lookup client]
  D --> E[Slack presence API]
  E --> F[Presence transition event]
  G[Provider shutdown] --> H[Abort in-flight lookup]
  H --> C
Loading

Before merge

  • Resolve merge risk (P1) - Merging changes the availability behavior of Slack presence polling by moving it onto a separate abortable client with a hard deadline; refresh the branch against current main and retain the focused shutdown and rate-limit proof on the exact merge head.
  • Complete next step (P2) - No concrete repair is required from ClawSweeper: the remaining action is ordinary maintainer review after the branch is refreshed against current main.
Agent review details

Security

None.

PR surface

Source +65, Tests +203. Total +268 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 79 14 +65
Tests 2 204 1 +203
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 283 15 +268

Review metrics

Metric Value Why it matters
Production versus test delta production +65 net, tests +203 net The production growth is tied to the named provider/monitor ownership boundary, while the larger test delta exercises timeout continuity, Retry-After cursor handling, and transport abort cleanup.

Merge-risk options

Maintainer options:

  1. Refresh the exact merge head (recommended)
    Rebase or merge current main into this branch, then rerun the focused presence and provider-shutdown proof before landing the availability-sensitive lifecycle change.
  2. Accept the reviewed lifecycle change
    Land with the supplied real-SDK loopback proof if maintainers accept the bounded timeout and cancellation behavior for configured presence events.

Technical review

Best possible solution:

Land the bounded, lookup-only client design after refreshing against current main and confirming the focused presence-monitor and provider-shutdown regressions still pass; keep the shared Bolt client unchanged for mutation traffic.

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

Yes. The supplied current-main run documents that a never-resolving first Slack lookup prevents the next user from polling and leaves both polling and stop unsettled; current source confirms that active task is awaited without a request deadline.

Is this the best way to solve the issue?

Yes. A separate read-only lookup client is the narrowest maintainable fix because it can enforce timeout and lifecycle cancellation without changing the shared Bolt client’s mutation behavior or public configuration.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: A stalled Slack presence lookup can indefinitely block configured presence polling and delay provider shutdown or restart.
  • merge-risk: 🚨 availability: The PR changes timeout and abort behavior for a live Slack polling path, so a merge-head refresh should reconfirm shutdown and polling continuity.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR body contains after-fix real @slack/web-api loopback output showing timeout continuity, Retry-After suppression and cursor preservation, plus provider-stop socket abort and bounded settlement; no sensitive values are exposed in the supplied transcript.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body contains after-fix real @slack/web-api loopback output showing timeout continuity, Retry-After suppression and cursor preservation, plus provider-stop socket abort and bounded settlement; no sensitive values are exposed in the supplied transcript.

Evidence

What I checked:

  • Current-main failure boundary: Current main serially awaits each users.getPresence call and its stop path awaits the active polling task; there is no request deadline or provider-owned cancellation path at that boundary, so a never-settling request can block later users and shutdown. (extensions/slack/src/monitor/presence-monitor.ts:271, 0cad02313a9c)
  • Root-cause repair on the PR head: The branch applies a 30-second monitor deadline, stops and records Retry-After rate limiting without consuming the failed cursor position, and advances the cursor only for settled non-rate-limited attempts. (extensions/slack/src/monitor/presence-monitor.ts:253, 7365dbf61a31)
  • Transport lifecycle ownership: The branch creates a no-retry lookup-only WebClient with the existing 30-second Slack read timeout and composes its fetch signal with a provider lifecycle AbortController; teardown aborts that controller before awaiting the monitor. (extensions/slack/src/monitor/provider.ts:637, 7365dbf61a31)
  • Existing SDK-option contract: Current main’s lookup-client helper explicitly rejects rate-limited calls, disables retries, and uses the canonical 30-second read timeout, which matches the branch’s monitor handling instead of changing the shared mutation-capable Bolt client. (extensions/slack/src/client-options.ts:127, 0cad02313a9c)
  • Feature provenance and likely routing: Scoped presence events were introduced by the feature commit; the current lookup-client timeout and rate-limit contract was most recently maintained in the Slack client-options work. (extensions/slack/src/monitor/presence-monitor.ts:253, 9317aadaa2f3)
  • Patch hygiene and supplied real behavior proof: The branch is clean under git diff --check. Its PR body provides after-fix real @slack/web-api loopback evidence for a timed-out request continuing to the next user, rate-limit backoff/cursor preservation, and shutdown aborting the stalled socket in 3 ms. (extensions/slack/src/monitor/provider.auth-test-token.test.ts:344, 7365dbf61a31)

Likely related people:

  • steipete: Introduced the opt-in Slack presence-events feature whose monitor and lifecycle behavior this PR repairs. (role: feature introducer; confidence: high; commits: 9317aadaa2f3; files: extensions/slack/src/monitor/presence-monitor.ts, extensions/slack/src/monitor/provider.ts)
  • joshavant: Recent current-main work owns the Slack lookup-client timeout and rate-limit contract reused by this patch. (role: recent area contributor; confidence: high; commits: d6f964513f14; files: extensions/slack/src/client-options.ts, extensions/slack/src/monitor/provider.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-08-01T15:52:15.931Z sha 084b3d692035fa6e72e448e059909aa23e621651 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T19:18:01.332Z sha 084b3d692035fa6e72e448e059909aa23e621651 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T19:32:12.354Z sha 084b3d692035fa6e72e448e059909aa23e621651 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-02T02:47:51.821Z sha 084b3d692035fa6e72e448e059909aa23e621651 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-03T01:29:03.865Z sha 084b3d692035fa6e72e448e059909aa23e621651 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Aug 1, 2026
@zhangguiping-xydt
zhangguiping-xydt force-pushed the fix/problem-slack-presence-poll-timeout branch from 084b3d6 to 7365dbf Compare August 3, 2026 08:38
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 3, 2026
@jalehman jalehman self-assigned this Aug 3, 2026
@jalehman
jalehman merged commit b026d35 into openclaw:main Aug 3, 2026
91 of 93 checks passed
@jalehman

jalehman commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 3, 2026
…-state-mutation

* origin/main: (22 commits)
  fix(delivery): renew stable producer leases (#118663)
  test(mcp): isolate catalog size checks from wall-clock load (#118871)
  test(ui): add credentials primary QA proof (#118790)
  fix(slack): prevent stalled presence polling from hanging shutdown (#117478)
  test(security): cover gateway shared auth modes (#118834)
  fix(macos): show gateway auth failures in app status (#118841)
  test(tui): route PTY gateway scenarios through explicit models (#118802)
  test(qa): add session transcript primary coverage (#118820)
  fix(browser): protect private observation media and Canvas trust boundaries (#118775)
  fix(build): restore SDK packages and signed macOS app builds (#118833)
  test(qa): cover plugin authoring contracts (#118821)
  fix(parallels): keep provider keys out of POSIX job logs (#118840)
  improve: reduce redundant Code Mode test work (#118815)
  fix(models): report primary OpenRouter limits in scans (#110855)
  test: speed up setup inference fixtures (#118811)
  fix(auto-reply): enforce canonical reset authorization (#118580)
  docs(gateway): fix invalid heartbeat visibility examples (#118827)
  fix(plugins): unify HTTP route conflict handling (#118203)
  test(agents): use prepared auth fixtures (#118816)
  fix(lmstudio): resolve JIT embedding variants
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 4, 2026
…penclaw#117478)

* fix(slack): prevent presence polling from hanging shutdown

* fix(slack): honor presence polling rate limits

* fix(slack): preserve presence polling cursor on rate limits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: slack Channel integration: slack merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M 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