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

feat: only one process for the server #4

Open
2 of 4 tasks
aheissenberger opened this issue Apr 19, 2024 · 4 comments
Open
2 of 4 tasks

feat: only one process for the server #4

aheissenberger opened this issue Apr 19, 2024 · 4 comments

Comments

@aheissenberger
Copy link
Contributor

aheissenberger commented Apr 19, 2024

Hi Rafael,

you did an amazing job in getting this working!!

Have a look at my changes to your rss.ts and rsc.ts which allow to only have one running process and bun.serve as the http server:
https://github.com/aheissenberger/r19/tree/bon-one-server

The new server is in ssr-bun.ts. Pages can be build with bun run bunbuild and then starte the server with bun start

  • the plugin rsc-conditions-plugin will include the rsc-bun.rsc.ts file with the condition react-server
  • the bun.serve only needs one port and uses the parameter ?__RSA to return rsc json code

problems:

  • homepage need to be loaded twice to show center component - have not found the reason for TypeError: Expected Sink on first call - fixed it with removing streaming
  • not pre-rendered static pages as the error will break the homepage

next planned steps:

  • code cleanup
  • remove the need for the extra build step for the pages
  • add hot reloading of the html
  • replace bun.serve with Hono to allow easy deployment to different providers
@rafaelrcamargo
Copy link
Owner

Hmm, that’s really, really interesting. I had not thought about a bun plugin to apply the conditions for the framework itself. This sounds promising; I will look into that over the weekend.

If you want some references to maybe figure out those weird behaviors in the meantime, Kotekan has a similar setup.

@aheissenberger
Copy link
Contributor Author

It would also help if someone can implement the option to add conditions for resolve in bun:
oven-sh/bun#1527

@aheissenberger
Copy link
Contributor Author

I did look at Kotekan but this implementation is using the multiple process architecture.

My current implementation needs only one process and supports hot reloading in the dev mode bun run start-dev see file ssr-bun-dev.ts. The hot reload library sometime fails to open a socket and currently only supports one build config. I will rewrite this lib to support multiple configs.

@rafaelrcamargo
Copy link
Owner

rafaelrcamargo commented Apr 19, 2024

I did look at Kotekan but this implementation is using the multiple process architecture.

Yeah, I only mentioned in case you wanted to have a different reference to the rendering process.

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

No branches or pull requests

2 participants