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

Automatically set stream: 'web' #31

Open
brillout opened this issue Dec 10, 2024 · 10 comments
Open

Automatically set stream: 'web' #31

brillout opened this issue Dec 10, 2024 · 10 comments

Comments

@brillout
Copy link
Member

brillout commented Dec 10, 2024

To avoid this error: #30.

See https://vike.dev/stream.

Let's do this after we make vike-node a Vike extension.

Note

It's currently a Vite plugin and not a Vike extension. We'll be able to make it a Vike extension after we implemented the Vike CLI.

Edit: instead of using stream let's create a new settting streamType: 'node' | 'web', so that the user can still enable/disable streaming.

@magne4000
Copy link
Member

Is this still relevant?

@brillout
Copy link
Member Author

Yea, I think so: universal-middleware and thus vike-server both don't supports Node.js streams?

@magne4000
Copy link
Member

magne4000 commented Mar 20, 2025

I'm wondering if this fix could have made the current issue deprecated.
If not, Vike could auto convert from one type of stream to the other automatically IMO, thus avoiding the need to specify the stream type manually.

@brillout
Copy link
Member Author

Correct me if I'm wrong but I don't think we can convert a Node.js stream to a Web stream.

Fundamentally, universal-middleware forces vike-{react,vue,solid} to create a Web stream instead of a Node.js stream.

@magne4000
Copy link
Member

Correct me if I'm wrong but I don't think we can convert a Node.js stream to a Web stream.

We can, there even is a native way to do it with Readable.toWeb

@brillout
Copy link
Member Author

Oh, nice, ok we can try that then 👌

@brillout
Copy link
Member Author

One drawback is that it's labeled as experimental and, in general, it may cause issues? Do we strictly need to convert? Maybe it would be wiser to tell vike-{react,vue,solid} to create a Web stream instead of a Node.js stream.

@magne4000
Copy link
Member

I wouldn't worry to much about it being experimental, it has been here for multiple years now.
I also agree that we should try to create the right type of stream to begin with, and such conversion could just be a fallback then.

@brillout
Copy link
Member Author

👍

@brillout
Copy link
Member Author

Streams are quite complex, so I'd even say there is a risk implementing a fallback disincentivizes doing it right. If there is a use case for falling back it's good to know we can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants