Skip to content

Websocket example type error #241

@dadamssg

Description

@dadamssg

TanStack AI version

v0.2.2

Framework/Library version

v0.2.2

Describe the bug and the steps to reproduce it

The documentation shows an example websocket adapter here: https://tanstack.com/ai/latest/docs/guides/connection-adapters#websocket-adapter-example

However, when i attempt that it produces a type error since the stream utility expects the factory function to return an AsyncIterable<StreamChunk>, not a readable stream.

I'm using this in a react router app where the typescript compilerOptions target is ES2022 which i think has something to do with the problem. I get no error in the typescript playground if i leave it on the default value of ES2017

Also, I'm not sure i understand how it's supposed to work. I believe it will create a new websocket connection on every user message send but i can't determine when/how that connection gets closed between user message sends.

I was hoping a single websocket connection could be opened and used for the life of the conversation.

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

https://www.typescriptlang.org/play/?target=9#code/JYWwDg9gTgLgBAbzjAnmApnAwhAdr9AYxmDwEEATAQzBnSgBo4BnGKdKkJgV2fSwAWVeAF84AMygQQcAEQABGFVysqhANYB6KsAC07NTFkBuAFChIsZGkxIAshAroANnfTNmVAObomAZTYOEEFuXHU4MUlpOUVlVQ1tYBNTU3FQ4lJcOEIDOgB1dAAjPwgNdBhKGjooAApuKGcALhY2YFwvAEpmnHwiEnJqWnpEUzg4dhh6rNYDEBrRsbgqZhRcQjgakHdPH2ZmhydXbe90AG0AXSZqJQB+ZoAlImgKAB4Ztq8mZRQAPg64AC8PxGi0WEymcAIAHc4I8qNRCs50AFZi8UUEQmEfjUEAtQWNlqt1qpYDVCHg2BBnEioP9cfj8eSVPAocxAZD0DCCsVSupynUGh0zHiGXBWQA6PAQDBZAEbf5AkGi0ESvi4Cg1ABSfgA8gA5cXvdrAcQoHFwLYeE7MJjiu3XKgRDpCkUMkTC5VjCV4S07TBymroABu6FwMAVwPpnrGTNY2QEoXCcu1+vFYCoUD4gZDYfFDpd0ZjFKk1Po4tDAEduOhq2SE2EC573Slo96CFApFB2YGO9AI0ro0zKaWoOXe7V6J3G8rm678W3CM4IHxu-2o4Pi1SaeLF8v0DVp6LmzOGHORIeRKexi6REA

Screenshots or Videos (Optional)

Image

Do you intend to try to help solve this bug with your own PR?

None

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions