router icon indicating copy to clipboard operation
router copied to clipboard

SSR streaming is throwing error

Open Mangor1no opened this issue 1 year ago • 4 comments

Describe the bug

I'm having this error in my console when trying to setup and run the basic-ssr-streaming-file-based example: Error: React currently only supports piping to one writable stream. The example on Stackblitz is also seems to be broken with this error message: Upgrade Required

Your Example Website or App

https://stackblitz.com/github/tanstack/router/tree/main/examples/react/basic-ssr-streaming-file-based?embed=1&theme=dark&preset=node&file=src/main.tsx

Steps to Reproduce the Bug or Issue

  1. Clone the project and do the setup following by the provided guide from Tanstack Router repository
  2. Run the project

Expected behavior

The URLs got served normally

Screenshots or Videos

Screenshot 2024-06-03 at 16 29 52

Platform

  • OS: MacOS 13.2.1, M1 Chip
  • Browser: Chrome
  • Version: 125.0.6422.114

Additional context

No response

Mangor1no avatar Jun 03 '24 09:06 Mangor1no

Any update on this issue? wanted to try the examples out myself before commiting to anything and this not allowing me to do so

glasody avatar Jun 14 '24 04:06 glasody

@TkDodo @tannerlinsley can you please take a look at the example when you have time? Much appreciate it :D

Mangor1no avatar Jun 14 '24 08:06 Mangor1no

Weird because I have even more basic problems with that example. First, request seems to be incorrectly passed as req (see also createRequestHandler type):

file:///C:/Users/sh4dow/temp/basic-ssr-streaming-file-based/node_modules/@tanstack/start/dist/esm/server/createRequestHandler.js:18
    const url = new URL(request.url, "http://localhost");
                                ^

TypeError: Cannot read properties of undefined (reading 'url')
    at file:///C:/Users/sh4dow/temp/basic-ssr-streaming-file-based/node_modules/@tanstack/start/dist/esm/server/createRequestHandler.js:18:33
    at Module.render (C:/Users/sh4dow/temp/basic-ssr-streaming-file-based/src/entry-server.tsx:15:5)
    at file:///C:/Users/sh4dow/temp/basic-ssr-streaming-file-based/server.js:76:13

But after correcting that, there's another error. Apparently, the express request object isn't compatible (which typescript complains about as well):

file:///C:/Users/sh4dow/temp/basic-ssr-streaming-file-based/node_modules/@tanstack/start/dist/esm/server/defaultStreamHandler.js:40
        ...isbot(request.headers.get("User-Agent")) ? {
                                 ^

TypeError: request.headers.get is not a function
    at defaultStreamHandler (file:///C:/Users/sh4dow/temp/basic-ssr-streaming-file-based/node_modules/@tanstack/start/dist/esm/server/defaultStreamHandler.js:40:34)
    at file:///C:/Users/sh4dow/temp/basic-ssr-streaming-file-based/node_modules/@tanstack/start/dist/esm/server/createRequestHandler.js:30:12

(Also, dependencies for React, React DOM types (which causes a ton of jsx type errors) and arguably typescript are missing.)

s-h-a-d-o-w avatar Aug 14 '24 11:08 s-h-a-d-o-w

can config issue example doesnt work

romanlex avatar Aug 25 '24 12:08 romanlex

This is resolved as part of #4495. New docs is pending #4527

nlynzaad avatar Jun 26 '25 21:06 nlynzaad