-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: resolve orchestrator subtask cancellation during API streaming error (#4896) #4905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -204,7 +204,21 @@ export const webviewMessageHandler = async ( | |||||||||||||||||
| // Check if the current task actually has a parent task | ||||||||||||||||||
| const currentTask = provider.getCurrentCline() | ||||||||||||||||||
| if (currentTask && currentTask.parentTask) { | ||||||||||||||||||
| await provider.finishSubTask(t("common:tasks.canceled")) | ||||||||||||||||||
| // For subtasks, we need to ensure the parent task is resumed even if the subtask is in an error state | ||||||||||||||||||
| try { | ||||||||||||||||||
| // First abort the current subtask if it's still running | ||||||||||||||||||
| if (currentTask.isStreaming || !currentTask.didFinishAbortingStream) { | ||||||||||||||||||
| currentTask.abortTask() | ||||||||||||||||||
| // Small delay to ensure abort signal is processed before cleanup | ||||||||||||||||||
| // This prevents race conditions where the stream might still be processing | ||||||||||||||||||
| await new Promise((resolve) => setTimeout(resolve, 100)) | ||||||||||||||||||
|
||||||||||||||||||
| await new Promise((resolve) => setTimeout(resolve, 100)) | |
| await new Promise((resolve) => setTimeout(resolve, ABORT_DELAY_MS)) |
Copilot
AI
Jun 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This finishSubTask call appears both inside the try and catch blocks; consider moving it after the try/catch to avoid duplication and centralize cleanup.
| await provider.finishSubTask(t("common:tasks.canceled")) | |
| } catch (error) { | |
| // If there's an error, still try to resume the parent task | |
| provider.log(`Error during subtask cancellation: ${error}`) | |
| } catch (error) { | |
| // If there's an error, still try to resume the parent task | |
| provider.log(`Error during subtask cancellation: ${error}`) | |
| } finally { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
abortTaskreturns a promise, consider awaiting it (e.g.,await currentTask.abortTask()) to ensure the abort completes before continuing.