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: Cancel streams in nodesdk #9

Open
humanagent opened this issue Feb 27, 2025 · 2 comments
Open

Feature request: Cancel streams in nodesdk #9

humanagent opened this issue Feb 27, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@humanagent
Copy link
Collaborator

humanagent commented Feb 27, 2025

A way to easily cancel streams like in reactnative cancelStream() but in node-sdk

https://github.com/xmtp/xmtp-react-native/blob/2a3cd0a67b5fdb775155f1d9b5dac0da51b8d502/src/lib/Conversations.ts#L450-L468

@humanagent humanagent added the enhancement New feature or request label Feb 27, 2025
@humanagent
Copy link
Collaborator Author

This is happenning consistently in our GM bot

Image

@humanagent humanagent changed the title Feature request: Cancel streams in nodesdk Bug: [agents] Feature request: Cancel streams in nodesdk Feb 28, 2025
@humanagent humanagent changed the title Bug: [agents] Feature request: Cancel streams in nodesdk Feature: Cancel streams in nodesdk Mar 2, 2025
@humanagent humanagent changed the title Feature: Cancel streams in nodesdk Feature request: Cancel streams in nodesdk Mar 2, 2025
@humanagent
Copy link
Collaborator Author


  async terminate() {
    if (this.isTerminated) {
      return super.terminate(); // Already terminated, just call parent
    }

    this.isTerminated = true;

    try {
      // Close streams if they exist
      if (
        this.messageStream &&
        typeof this.messageStream.return === "function"
      ) {
        await this.messageStream.return();
      }
    } catch (error) {
      console.error(`[${this.nameId}] Error during stream cleanup:`, error);
    }

    // Call parent terminate
    return super.terminate();
  }

@humanagent humanagent reopened this Mar 8, 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
Projects
None yet
Development

No branches or pull requests

1 participant