fix(queue): survive a synchronous task throw in SerialQueue - #892
Open
YOMXXX wants to merge 2 commits into
Open
Conversation
Issue TencentCloud#851: the plugin used to monkey-patch OpenClaw's compiled dist files to inject event.messages into after_tool_call. The patch is removed in v2, but the hook still gated L3 compression on classifyPatchEffectiveness() and relied on the injected messages — on current OpenClaw versions (where event.messages is absent) L3/MMD never ran. - after_tool_call now fetches session messages through the official api.runtime.subagent.getSessionMessages({ sessionKey, limit }) when the event carries none - removed the classifyPatchEffectiveness() patch check (the patch no longer exists) - the handler takes an optional getSessionMessages callback, wired from the plugin api at registration Fixes TencentCloud#851 (replaces the fragile dist-patch approach with the supported API) Signed-off-by: 李冠辰 <liguanchen@xiaomi.com>
drain() invoked entry.task() directly; when a queued task threw synchronously the call escaped before .finally() was registered, leaving running=true forever. The queue stayed stuck, so every later add() hung and onIdle() never resolved — silently stalling L1/L2/L3 flushes in the pipeline. Wrap the task call in Promise.resolve().then() so the error is caught, bookkeeping is finalized, and the next queued task runs normally. Fixes TencentCloud#518 Signed-off-by: 李冠辰 <liguanchen@xiaomi.com>
Collaborator
|
Thanks for your contribution and attention! We will review this PR and get back to you as soon as possible. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #518.
Problem
SerialQueue.drain()calledentry.task()directly. If a queued task throws synchronously, the call escapes before the.finally()handler is registered — the promise returned byadd()rejects, but the queue stays permanently stuck withrunning = true.This affects all three pipeline queues (L1/L2/L3,
pipeline-manager.ts). Subsequent tasks never start, and callers such asflushSession()and_doFlush()can wait forever ononIdle().Reproduction (on
main):Change
Invoke the task from a resolved promise (
Promise.resolve().then(() => entry.task())) so a synchronous throw is routed through the catch/finally chain and queue bookkeeping is finalized.Verification
src/utils/serial-queue.test.ts(4 tests): sync-throw recovery, FIFO order across mixed tasks,onIdle()after a sync-throw, and no double-run.npm test+npm run build:pluginpass.