Skip to content

Gracefully handle "Stop" button when streaming #101

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

Open
corinagum opened this issue Mar 19, 2025 · 0 comments
Open

Gracefully handle "Stop" button when streaming #101

corinagum opened this issue Mar 19, 2025 · 0 comments

Comments

@corinagum
Copy link
Contributor

copy-pasted from teams-ai repo:

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

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

No branches or pull requests

1 participant