Repository navigation
fix(slack): avoid shutdown stalls during Socket Mode retries - #188745
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs changes before merge. What this changesThis PR settles cancelled Slack Socket Mode retries so stopped account monitors can release their plugin resources. Example: apps.connections.open returns internal_error and the account stops during its 15-second retry delay.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep open: this PR fixes a concrete pending-startup leak that remains on main, with no introduced correctness defect found; the draft has confirmed merge conflicts. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe Slack monitor awaits Bolt startup while Gateway custody retains its plugin instance; SDK retry cancellation must settle that startup before retirement can finish. flowchart TD
A[Account stop] --> B[Slack monitor]
B --> C[Bolt Socket Mode client]
C --> D[Retry timer and promise]
D --> E[Startup settles]
E --> F[Gateway releases plugin custody]
F --> G[Plugin retirement completes]
Technical reviewBest possible solution: Keep cancellation settlement in the existing Slack retry scheduler while preserving SDK timer ownership and Gateway custody checks. Do we have a high-confidence way to reproduce the issue? Yes: the pinned SDK clears the pending retry timer on disconnect while current main awaits a promise settled only by that timer; the PR also records red-on-base SDK regressions. Is this the best way to solve the issue? The patch repairs the unresolved promise at its existing owner, preserves native reconnect behavior, and needs no additional state, fallback, or retirement exception. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d107cb81b327. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +11, Tests +38, Docs +17, Other +151. Total +217 across 7 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 30, 2026, 6:12 PM ET / 22:12 UTC. |
6722358 to
50a652d
Compare
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
Release adaptation: backport only the Socket Mode reconnect waiter owner and focused regression tests; omit the performance harness and main-only transport documentation addition. Add listener-count assertions for timer settlement and disconnect cancellation; adjust the test allocation to 41. Companion dispositions: #198007 is specific to SDK 3.2 callback/abort semantics and is not applicable to this line pinned to socket-mode 3.1.0. #197657 retires main allocations; other audit hits (#200523, #197009, #194964, #184507, #192197, #192051, #190003, #189850) only overlap the excluded shared perf README. No later #188745 mention through bd692e9. (cherry picked from commit a1d1da7) Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Fixes Gateway shutdown spending the full metadata-retirement grace period and reporting retained plugin resources when a Slack Socket Mode startup is stopped while retrying its connection URL.
User Impact
Slack account stop and reload can finish releasing plugin custody instead of leaving an old monitor pending. No configuration or migration is required.
Why This Change Was Made
The SDK clears its reconnect timer on disconnect, but OpenClaw's patched scheduler left the promise behind that timer unresolved. Startup awaited that promise, so the channel monitor never reached its custody-release
finallyblock. Settle the pending retry on the SDK's existing disconnect event, and settle retries admitted after stop immediately. Preserve the SDK distinction between fire-and-forget native restarts and awaited URL retrieval; remove the listener when the timer runs normally.The fix stays in the Slack owner and preserves core retirement checks. Runtime production delta is +11 lines, needed for promise settlement and listener cleanup. The regression delta is +38 lines: the installed SDK is exercised with stop before and after retry admission, and the existing native-restart test now checks settlement. A separate test-line allocation records that growth. The rerunnable synthetic benchmark adds 148 tooling lines.
Evidence
provider.interop.test.ts,provider.reconnect-loop.test.ts, andprovider.ingress-start-cleanup.test.ts. The original local invocation took 198.90 s; the integrated candidate also passed all 26 tests in 214.41 s (mostly worker compilation). Exact-head CI ran for a 7m54s job span: 31 jobs succeeded, 27 skipped, and the test-line ratchet plus its aggregate gate failed (run 41140725084, attempt 1).pnpm check:changed: passed before the conflict-only integration (including extension/test/script typechecks, lint, exports, and repository-policy guards). The integration drops a redundant per-script Knip entry now covered by main’s existing performance-script glob; runtime and test changes are identical.528b92792ed041366e037d084041369f93d244a7: scoped-clean through P2, no accepted/actionable findings. Simplification pass retains one scheduler owner and no new caches or retirement fallback.The committed probe runs 44 real plugin instances and one real Slack SDK monitor with synthetic API responses through channel custody and cache retirement. Five serial A/B pairs on source base
77869fe2570cwith Node 26.12.1, after A/A controls:A/A total timings were 5005.832/5004.519 ms before and 7.567/7.644 ms after. Separate sampled allocations were 2,641,112/2,568,288 bytes. CPU ranges overlap and the host was busy; no CPU or allocation reduction claim. The reliable result is elimination of the five-second wait and retained consumer. Separately, the updated generation owner on main
528b92792ed0with Node 24.22.1 reproduces the failure at 5033.036 ms; the integrated fix retires cleanly at 7.688 ms with zero consumers. This single pair verifies integration and is not mixed into the earlier distribution.Reproduce with
node --expose-gc --import ./scripts/tsx.mjs scripts/perf/slack-shutdown-retirement-measure.ts; add--allocationsseparately. Timing excludes imports/setup. This owner does no database or workspace I/O, so this is lifecycle proof, not whole-Gateway state-scale performance. The synthetic failure matches the retained-resource signature, but does not establish the exact await point in an earlier production incident.CI's tested merge
f12e8da20f926dcf74a40ee7e4c291904ff8e21dused main baseb39e2d09329cc81b09cf55980a2506623236ea59. Its only test-line delta is +38 LF lines with an equal +38 allocation. The ratchet reports 6,314,087 lines against 6,313,062 credit, an inherited 1,025-line overage. An exact Git-blob census of the CI base finds 6,314,049 test LF lines against 6,313,024 credit: the same 1,025-line debt before this PR. The checker and shared scalar are unchanged, and the PR’s +38 test/+38 allocation pair preserves that debt exactly. The scheduled-main comparison labeled this job new because its older main job passed; this exact-base attribution is stronger than that job-name comparison. The shared baseline remains unchanged. CI is recorded as failed, not green.