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

RSC: Make RWJS_ENV etc available on the server during runtime #9971

Merged
merged 1 commit into from
Feb 7, 2024

Conversation

Tobbe
Copy link
Member

@Tobbe Tobbe commented Feb 7, 2024

  1. First thing we need to realize here is that Redwood framework files that use global environment variables like RWJS_API_URL or __REDWOOD__APP_TITLE will still have those unresolved after building the framework.
  2. They will also still be unresolved after building the RW app itself, because building the app doesn't touch the already built FW files in node_modules.
  3. This means they need to be resolved during runtime.
  4. For yarn rw dev we set those global environment variables in the dev server config
  5. For yarn rw serve we call registerFwGlobals() to register them
  6. When serving an RSC enabled app we spin up a worker thread to handle rendering server components to flight format.
  7. The worker thread runs in its own thread and does not share global variables with the main server process, so we need to also register the global variables for the worker.

@Tobbe Tobbe added the release:fix This PR is a fix label Feb 7, 2024
@Tobbe Tobbe added this to the RSC milestone Feb 7, 2024
@Tobbe Tobbe enabled auto-merge (squash) February 7, 2024 08:12
@Tobbe Tobbe disabled auto-merge February 7, 2024 08:15
@Tobbe Tobbe merged commit f736662 into redwoodjs:main Feb 7, 2024
41 of 44 checks passed
@Tobbe Tobbe deleted the tobbe-rsc-worker-rwjs-env branch February 7, 2024 08:37
@Josh-Walker-GM Josh-Walker-GM modified the milestones: RSC, v8.0.0 Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:fix This PR is a fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants