Repository navigation
fix(feishu): honor abortSignal in drive comment reply retry loop - #108408
Conversation
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: needs maintainer review before merge. Reviewed July 16, 2026, 3:01 AM ET / 07:01 UTC. Summary PR surface: Source +27, Tests +49. Total +76 across 5 files. Reproducibility: yes. with high confidence from the existing bare-delay source path and the supplied before-run harness showing four reply fetches after account cancellation; it was not independently rerun against the exact current-main SHA during this read-only review. Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Refresh the branch onto current main if needed, preserve the single account-owned cancellation signal and shared abortable-delay helper, then merge with the focused regression test and supplied runtime proof intact. Do we have a high-confidence way to reproduce the issue? Yes, with high confidence from the existing bare-delay source path and the supplied before-run harness showing four reply fetches after account cancellation; it was not independently rerun against the exact current-main SHA during this read-only review. Is this the best way to solve the issue? Yes. Reusing the plugin’s shared abortable-delay helper and forwarding the existing lifecycle signal through the owning handler chain is narrower and more maintainable than adding config, another retry engine, or a separate cancellation source. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 863443fac8c3. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +27, Tests +49. Total +76 across 5 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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
Review history (3 earlier review cycles)
|
|
@clawsweeper re-review |
The inter-attempt delay in monitor.comment.ts used a bare setTimeout and never received the owning monitor account's AbortSignal, so an account teardown (ws disconnect, webhook stop, config reload) left the in-flight comment reply retry running for up to ~6s after the rest of the lifecycle settled. delayMs now wraps waitForAbortableDelay from async.ts and the abortSignal is threaded through fetchDriveCommentContext → resolveDriveCommentEventTurn → handleFeishuCommentEvent → createFeishuDriveCommentNoticeHandler, sourced from monitorSingleAccount. The retry loop checks the waitMs return value and the abortSignal flag, breaking out of the next 1s tick instead of running the full 6×1s poll budget. Sibling surface monitor.bot-identity.ts already uses the same pattern; openclaw#104431 explicitly skipped the comment-monitor retry because it is a result-predicate poll, not an error retry, and this fix is orthogonal to that decision. Not tested: live Feishu tenant, real bot identity, real drive comment, and account restart. requestFeishuOpenApi itself does not accept AbortSignal — that is a separate, larger refactor and is out of scope.
4f1c0e9 to
8b751d1
Compare
|
Maintainer review complete. Improved the patch to use the existing abortable-delay helper directly, replaced the injected-delay test with a real fake-timer regression against a mocked Feishu OpenAPI client, and pinned signal propagation through the notice and comment-handler boundaries. Proof:
No actionable findings remain. Preparing to merge. |
|
Merged via squash.
|
…nclaw#108408) * fix(feishu): honor abortSignal in drive comment reply retry loop The inter-attempt delay in monitor.comment.ts used a bare setTimeout and never received the owning monitor account's AbortSignal, so an account teardown (ws disconnect, webhook stop, config reload) left the in-flight comment reply retry running for up to ~6s after the rest of the lifecycle settled. delayMs now wraps waitForAbortableDelay from async.ts and the abortSignal is threaded through fetchDriveCommentContext → resolveDriveCommentEventTurn → handleFeishuCommentEvent → createFeishuDriveCommentNoticeHandler, sourced from monitorSingleAccount. The retry loop checks the waitMs return value and the abortSignal flag, breaking out of the next 1s tick instead of running the full 6×1s poll budget. Sibling surface monitor.bot-identity.ts already uses the same pattern; openclaw#104431 explicitly skipped the comment-monitor retry because it is a result-predicate poll, not an error retry, and this fix is orthogonal to that decision. Not tested: live Feishu tenant, real bot identity, real drive comment, and account restart. requestFeishuOpenApi itself does not accept AbortSignal — that is a separate, larger refactor and is out of scope. * test(feishu): prove comment retry abort --------- Co-authored-by: Peter Steinberger <[email protected]>
The bare setTimeout in ensureBrowserRunning prevents abort during the 250ms retry window. Replace with sleepWithAbort + .catch + throwIfAborted so the caller's abort signal cancels promptly while preserving the original abort reason in the error response. Add a real-timer production-route proof test exercising the actual registerBrowserTabRoutes handler with real performance.now() timers. Related: openclaw#108561, openclaw#108408
…nclaw#108408) * fix(feishu): honor abortSignal in drive comment reply retry loop The inter-attempt delay in monitor.comment.ts used a bare setTimeout and never received the owning monitor account's AbortSignal, so an account teardown (ws disconnect, webhook stop, config reload) left the in-flight comment reply retry running for up to ~6s after the rest of the lifecycle settled. delayMs now wraps waitForAbortableDelay from async.ts and the abortSignal is threaded through fetchDriveCommentContext → resolveDriveCommentEventTurn → handleFeishuCommentEvent → createFeishuDriveCommentNoticeHandler, sourced from monitorSingleAccount. The retry loop checks the waitMs return value and the abortSignal flag, breaking out of the next 1s tick instead of running the full 6×1s poll budget. Sibling surface monitor.bot-identity.ts already uses the same pattern; openclaw#104431 explicitly skipped the comment-monitor retry because it is a result-predicate poll, not an error retry, and this fix is orthogonal to that decision. Not tested: live Feishu tenant, real bot identity, real drive comment, and account restart. requestFeishuOpenApi itself does not accept AbortSignal — that is a separate, larger refactor and is out of scope. * test(feishu): prove comment retry abort --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Feishu's drive-comment reply lookup retries
FEISHU_COMMENT_REPLY_MISS_RETRY_LIMIT = 6times withFEISHU_COMMENT_REPLY_MISS_RETRY_DELAY_MS = 1_000between attempts when the requested reply is not immediately visible in the embedded batch payload. The inter-attempt delay inmonitor.comment.ts:367usedsetTimeout(resolve, ms)and never received the owning monitor account'sAbortSignal. WhenmonitorSingleAccount(line 469) tears down the websocket or webhook for an account restart, the in-flight comment retry loop runs through the full ~6 s poll-miss window instead of stopping with the rest of the account lifecycle.monitor.bot-identity.ts:40in the same plugin already uses the sharedwaitForAbortableDelay(ms, abortSignal)helper for the bot-identity recovery retry; only the comment reply retry path was unwired. The retry is exported throughfetchDriveCommentContext→resolveDriveCommentEventTurn→handleFeishuCommentEvent→createFeishuDriveCommentNoticeHandler; none of those signatures accepted anAbortSignal, so the handler had no way to forward the account-level stop.Why This Change Was Made
delayMsis now a thin wrapper overwaitForAbortableDelayfrom./async.jsand returnsPromise<boolean>(true = full delay elapsed, false = aborted). The retry loop checks the boolean and exits instead of starting another 1 s delay.fetchDriveCommentContext,ResolveDriveCommentEventParams,HandleFeishuCommentEventParams, andcreateFeishuDriveCommentNoticeHandlereach gain an optionalabortSignal?: AbortSignal;monitorSingleAccount(which already held the signal at line 469) is the source, threaded viaregisterEventHandlers.abortSignalstays optional everywhere — callers that never pass it get the old bare-setTimeoutbehavior viawaitForAbortableDelay(ms, undefined).#104431 (merged) explicitly kept this result-predicate poll off
retryAsync; this PR targets the delay-abort contract, orthogonal to that error-retry refactor.User Impact
Stopping or restarting a Feishu account no longer leaves a drive-comment reply retry loop running for up to ~6 s after the rest of the account has settled. The loop now exits on the abort event, the same cadence the sibling bot-identity recovery loop already follows. Happy-path behavior is unchanged — when the requested reply appears within the retry budget, the loop still breaks at the matching attempt.
Evidence
Fix before (base
1f9a9281d9; abort fires 374 ms into attempt 3's 1 s delay — the loop keeps polling for 3.6 s and 4 more fetches):Fix after (this head
4f1c0e99cf; same harness — the abort interrupts the delay, no post-stop fetch):Blind rerun of the fixed head:
elapsedMs:2507, replyFetchCount:3, replyFetchesAfterAbort:0.How the proof was produced
Uncommitted
scratchpad/feishu-comment-abort-proof.tsdrives the productionresolveDriveCommentEventTurnentry with nocreateClient/waitMsinjection: the client comes from the realcreateFeishuClientfactory with the accountdomainpointed at a loopbacknode:httpstub of the Feishu OpenAPI (the same custom-domain seam private deployments use), the abort is a realAbortControllerstanding in for the owning account signal, and all timers are real wall-clock. The stub serves tenant-token, doc-meta, and comment batch_query with replies that never contain the requestedreply_id, then countsGET …/replieshits server-side. The before run is the same harness against base1f9a9281d9.Mutation proof
Prod source stashed to
1f9a9281d9with only the test change applied → the new regression test fails:expected "vi.fn()" to be called 1 times, but got 6 times.Tests & checks
monitor.comment.test.ts17/17; focused feishu sweep (7 files) 82/82. Full-plugin sweep shows 17 pre-existing i18n failures on stock1f9a9281d9(LANG=zh_CN.UTF-8vs English string expectations), unrelated to this change.run-tsgo -p tsconfig.extensions.jsonexit=0;run-oxlinton 5 changed files exit=0;oxfmt --checkexit=0;git diff --checkclean.Prod-only non-test LOC:
+28 / -9across four files.Not tested: a live Feishu tenant with real bot credentials. The loopback run exercises the real production client factory, Lark SDK request path, and retry loop over real HTTP — only the upstream server is stubbed, and
requestFeishuOpenApitimeout behavior is intentionally untouched (bounded bytimeoutMs, a separate concern from the poll-delay abort).