Skip to content
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

[Feature Request]: Gracefully handle "Stop" button when streaming. #2318

Open
singhk97 opened this issue Feb 20, 2025 · 0 comments
Open

[Feature Request]: Gracefully handle "Stop" button when streaming. #2318

singhk97 opened this issue Feb 20, 2025 · 0 comments
Labels
enhancement New feature or request JS Change/fix applies to JS. If all three, use the 'JS & dotnet & Python' label .NET Pull requests that update .net code Python Change/fix applies to Python. If all three, use the 'JS & dotnet & Python' label

Comments

@singhk97
Copy link
Collaborator

Scenario

I'm using the JS SDK's StreamingResponse object to stream content to Teams. Here's a minimal repro to get streaming working using StreamingResponse:

app.activity(ActivityTypes.Message, async (context: TurnContext, _: ApplicationTurnState) => {
    const streamer = new StreamingResponse(context);
    streamer.setGeneratedByAILabel(true);
    streamer.setFeedbackLoop(true);
    streamer.setFeedbackLoopType('default');
    streamer.queueInformativeUpdate("Processing...");
    await sleep(1000);
    streamer.queueInformativeUpdate("Processing... 2");
    await sleep(1000);
    streamer.queueInformativeUpdate("Processing... 3");
    streamer.queueTextChunk("Hello");
    await sleep(500);
    streamer.queueTextChunk("Hello World");
    await sleep(100);
    await streamer.endStream();
});

And in Teams a "Stop" button pops up will streaming is in progress like this:

Image

When I click stop then I get this error in the console log:

RestError: Content stream was cancelled by user.
 {
  "name": "RestError",
  "code": "ContentStreamNotAllowed",
  "statusCode": 403,
  "request": {
    "streamResponseStatusCodes": {},
    "url": "<REDACTED>",
    "method": "POST",
    "headers": {
  "statusCode": 403,
  "request": {
    "streamResponseStatusCodes": {},
    "url": "<REDACTED>",
    "method": "POST",
    "headers": {
    "streamResponseStatusCodes": {},
    "url": "<REDACTED>",
    "method": "POST",
    "headers": {
    "method": "POST",
    "headers": {
      "_headersMap": {
        "content-type": "application/json; charset=utf-8",
        "content-type": "application/json; charset=utf-8",
        "x-ms-conversation-id": "REDACTED",
        "accept": "*/*",
        "user-agent": "Microsoft-BotFramework/3.1 botframework-connector/4.23.2 core-http/3.0.5 Node/v20.0.0 OS/(x64-Windows_NT-10.0.26100) teamsai-js/1.7.3",
        "authorization": "REDACTED"
      }
    },
    "withCredentials": false,
    "timeout": 0,
    "requestId": "ebe240b0-ca1c-4db7-b4ca-03c91deb75db"
  },
  "details": {
    "error": {
      "code": "ContentStreamNotAllowed",
      "message": "Content stream was cancelled by user."
    }
  },
  "message": "Content stream was cancelled by user."
}

Solution

Not sure what the solution is but there should be a way to gracefull handle this scenario in the StreamingResponse class itself.

Additional Context

No response

@singhk97 singhk97 added enhancement New feature or request Python Change/fix applies to Python. If all three, use the 'JS & dotnet & Python' label JS Change/fix applies to JS. If all three, use the 'JS & dotnet & Python' label .NET Pull requests that update .net code labels Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request JS Change/fix applies to JS. If all three, use the 'JS & dotnet & Python' label .NET Pull requests that update .net code Python Change/fix applies to Python. If all three, use the 'JS & dotnet & Python' label
Projects
None yet
Development

No branches or pull requests

1 participant