Skip to content

fix react-basic-ssr-streaming-file-based example #4429

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
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

nlynzaad
Copy link

The react basic-ssr-streaming-file-based example is a bit outdated and no longer working.

This fix updates the server.js and entry-server.tsx to match those of the basic-ssr-file-based example as these were using the new createRequestHandler and defaultStreamHandler.

This also addresses an issue with the index route where the deferred value is causing an error when accessing the getDate() function. The value when streamed in is not being transformed back into a date. I assume this will be addressed with the serializer re-write/seroval but until then this at least allows the example to run.

@schiller-manuel
Copy link
Contributor

thanks! can you please rename package.disabled.json back to package.json?

Copy link

nx-cloud bot commented Jun 14, 2025

View your CI Pipeline Execution ↗ for commit 1a45da5.

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 5m View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 2m 22s View ↗

☁️ Nx Cloud last updated this comment at 2025-06-16 22:42:14 UTC

@nlynzaad
Copy link
Author

Will do.

Was wondering why it was named as such but didn't want to change it.

@schiller-manuel
Copy link
Contributor

the name was just a way to disable it from building (and failing) in CI

@schiller-manuel
Copy link
Contributor

needs updating the lockfile as well

Copy link

pkg-pr-new bot commented Jun 14, 2025

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@4429

@tanstack/directive-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@4429

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@4429

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@4429

@tanstack/react-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@4429

@tanstack/react-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@4429

@tanstack/react-router-with-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-with-query@4429

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@4429

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@4429

@tanstack/react-start-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-plugin@4429

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@4429

@tanstack/router-cli

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@4429

@tanstack/router-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@4429

@tanstack/router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@4429

@tanstack/router-devtools-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@4429

@tanstack/router-generator

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@4429

@tanstack/router-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@4429

@tanstack/router-utils

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@4429

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@4429

@tanstack/server-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@4429

@tanstack/solid-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@4429

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@4429

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@4429

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@4429

@tanstack/solid-start-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-plugin@4429

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@4429

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@4429

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@4429

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@4429

@tanstack/start-server-functions-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-functions-client@4429

@tanstack/start-server-functions-fetcher

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-functions-fetcher@4429

@tanstack/start-server-functions-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-functions-server@4429

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@4429

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@4429

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@4429

commit: 1a45da5

@nlynzaad
Copy link
Author

nlynzaad commented Jun 14, 2025

I see it fails a the build test if '@tanstack/react-start' is not added to the ssr external array in vite for this example.

I've added it to the PR

@schiller-manuel
Copy link
Contributor

please don't merge this yet, we need to still figure out how to handle the ssr noExternal setting properly

@SeanCassiere
Copy link
Member

Trying this out locally, whilst this does work in dev, it doesn't seem to work once a production build has been made.

Copy link
Member

@SeanCassiere SeanCassiere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking this till we figure out both Manuel's comment and mine.

@nlynzaad
Copy link
Author

Thanks for looking at this.

I've made a couple of updates to resolve the ssr build actions for both server and client builds as well as serving in production.

When building this outside of the mono-repo this builds perfectly without the external clause and runs fine in prod and dev modes.

However as soon as we try and build it in the mono repo the below appears:

image

Honestly not too sure what might be the cause other than its clearly not able to resolve the virtual import in the mono-repo. If you have any ideas where to start looking I would be more than happy to continue scratching around and resolving it.

@nlynzaad
Copy link
Author

nlynzaad commented Jun 16, 2025

Scratched a bit further.

From what I can see the dependencies flow from start-server-core => react-start-server => react-start/server.

The virtual modules is part of start-server-core but does not get imported/used in the functions needed for the router ssr (non-start) functionality. However, this is included in the barrel exports and also marked as external dependencies in start-server-core. My guess is this is where it falls over when building in the mono-repo but passes when building for standalone.

By specifically marking the VIRTUAL_MODULES as external the build passes in both the mono-repo and standalone. And since this is not used (from what I can see) for SSR to function in a pure SPA router app this should not be a problem.

Also ran this through the test suite and it passes all tests.

Ideally this should not be making its way into the build process at all but I'm not familiar enough with nx mono-repos to understand how to exclude this specifically in the build and other than stripping it out into either separate exports or alternative package this seems to be the path of least resistance.

Open to any suggestions you might have.

@nlynzaad nlynzaad requested a review from SeanCassiere June 16, 2025 16:11
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

Successfully merging this pull request may close these issues.

3 participants