Skip to content

Prevent infinite stream iteration when func host task terminates#4887

Merged
nturinski merged 2 commits intonat/debuggerViewfrom
copilot/sub-pr-4883-another-one
Jan 15, 2026
Merged

Prevent infinite stream iteration when func host task terminates#4887
nturinski merged 2 commits intonat/debuggerViewfrom
copilot/sub-pr-4883-another-one

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 15, 2026

The async iteration over task.stream in the onFuncTaskStarted event handler could hang indefinitely when the task ends, as the stream might not close properly.

Changes:

  • Added AbortController to IRunningFuncTask to signal stream termination
  • Abort the stream iteration in onDidEndTask handler before removing task from map
  • Check abort signal in iteration loop to break cleanly
  • Wrapped iteration in try-catch to handle stream errors without crashing the extension
// In onDidEndTask handler
const task = runningFuncTaskMap.get(scope, cwd);
if (task?.streamAbortController) {
    task.streamAbortController.abort();
}

// In stream iteration loop
for await (const chunk of task.stream ?? []) {
    if (task.streamAbortController?.signal.aborted) {
        break;
    }
    // ... process chunk
}

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: nturinski <5290572+nturinski@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP address feedback on Function Host Debugger View Prevent infinite stream iteration when func host task terminates Jan 15, 2026
Copilot AI requested a review from nturinski January 15, 2026 00:14
@nturinski nturinski marked this pull request as ready for review January 15, 2026 00:17
@nturinski nturinski requested a review from a team as a code owner January 15, 2026 00:17
@nturinski nturinski merged commit db407f4 into nat/debuggerView Jan 15, 2026
1 check passed
@nturinski nturinski deleted the copilot/sub-pr-4883-another-one branch January 15, 2026 00:17
nturinski added a commit that referenced this pull request Mar 26, 2026
* Implementation for debug-isolated flag and streaming func CLI output

* Update src/utils/stream.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Address copilot feedback

* Refactor to set up stream in funcHostTasks

* Delete test snippet

* Add headerto stream file

* Remove the done call

* Update src/debug/FuncTaskProvider.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* WIP waiting for VSCode insiders fix

* Use onDidStartTerminalShellExecution API instead of proposed

* Remove proposed files

* Add note

* Remove unused async moniker

* Whoops, wrong async

* Little bit of cleaning

* Remove unusued function helper

* Last commit, I swears it

* Move event handler, added note

* Rename function due to PR feedback

* Push up WIP

* Push up WIP

* WIP for postDebug copilot analysis

* Add debug command activity

* WIP for copilot postdebug

* Merge with main

* Fix linter

* MVP for func debugger view

* Setting for debugger view, show first error

* Refactoring/cleaning up

* Remove the stop action and implement clear errors

* Clean up some code

* Remove the terminal dispose since it is not reinstantiated later

* Update src/funcCoreTools/funcHostTask.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/funcCoreTools/funcHostErrorUtils.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add JSDoc documentation for IStartFuncProcessResult stream property (#4885)

* Initial plan

* Add JSDoc documentation for IStartFuncProcessResult interface

Co-authored-by: nturinski <5290572+nturinski@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: nturinski <5290572+nturinski@users.noreply.github.com>

* Prevent infinite stream iteration when func host task terminates (#4887)

* Initial plan

* Add AbortController to prevent infinite stream iteration

Co-authored-by: nturinski <5290572+nturinski@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: nturinski <5290572+nturinski@users.noreply.github.com>

* Update src/debug/FunctionHostDebugView.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Remove exhaustive check from switch statement

Removed exhaustive check for FuncHostDebugNode.

* npm install to update package-lock

* Convert shell args to be an array

* Fix duplicate log entries, fix func start tasks with args not being recognized

* Clean up some of the code

* Fix imports in tests

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* PR feedback

* Debugger view always visible but collapsed by default

* Display stopped hosts as well

* Expose ask copilot on top level node

* Make labels a bit more descriptive

* Refactor into individual tree items

* Remove enums that are not shared

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Nathan Turinski <naturins@microsoft.comm>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: nturinski <5290572+nturinski@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants