-
Notifications
You must be signed in to change notification settings - Fork 1k
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(rsc-auth): Implement serverStore to hold and pass req info to RSC #10585
Conversation
Set serverStore after invoking middleware
…uth-store * 'main' of github.com:redwoodjs/redwood: chore(router): Add more code comments to analyzeRoutes (#10569) RSC: No need to use memo or useMemo in the server router (#10568) RSC: getViteConfig in rscWorker (#10567) Split RSC and RSA handling in rscWorker (#10565) RSC: Extract the fetchRSC function (#10564) RSC: Fix TODO regarding SSR in client.ts (#10562) Docs: QoL Updates to Contributing.md (#10561) Added warning note to not add WebAuthn (#10231) fix(rsc): Load all css links to support css with rsc (#10544) fix(cli): Add deprecation notice for edgio deployment (#10551) Define `process.env.NODE_ENV` in build process. (#10553) chore(docs): Update dbAuth and Supabase middleware READMEs (#10552) chore(deps): Upgrade React 19 to beta 20240508 (#10560) Revert "chore(deps): React beta 20240508 (#10558)" (#10559) chore(deps): React beta 20240508 (#10558) fix(functions): Fix context variable warning/error (#10556) fix(functions): Mock context in function test template (#10555) chore(middleware): Format code and comments and fix comment grammar (#10554)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dac09 Looks great. Had a question about moving to the web package but perhaps in a separate PR?
@@ -0,0 +1,74 @@ | |||
import { AsyncLocalStorage } from 'async_hooks' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dac09 do we want to move this into '@redwoodjs/web/serverStore'? In a separate PR?
If so '@redwoodjs/web/serverAuth
?
If would be nice to have auth in the import so one can distinguish auth from other store related things...
Perhaps @redwoodjs/web/serverAuth
and @redwoodjs/web/serverStore
when the serverAuth has auth specific methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm intentionally holding off this until we're done with the implementation DT :) - anticipating some challenges here.
@@ -49,7 +49,8 @@ export async function rscBuildForServer( | |||
noExternal: true, | |||
// Can't inline prisma client (db calls fail at runtime) or react-dom | |||
// (css pre-init failure) | |||
external: ['@prisma/client', 'react-dom'], | |||
// Server store has to be externalized, because it's a singleton (shared between FW and App) | |||
external: ['@prisma/client', 'react-dom', '@redwoodjs/vite/serverStore'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note if/when moving store to web will need to update here too so not bundled in
…erverStore * 'main' of github.com:redwoodjs/redwood: (66 commits) fix(deps): update dependency @graphql-yoga/plugin-graphql-sse to v3.3.1 (#10639) fix(deps): update graphql-tools monorepo (#10641) fix(deps): update dependency core-js to v3.37.1 (#10630) fix(deps): update dependency @graphql-yoga/plugin-persisted-operations to v3.3.1 (#10640) fix(deps): update dependency @graphql-yoga/plugin-defer-stream to v3.3.1 (#10638) chore(deps): update dependency firebase to v10.12.0 (#10635) chore(deps): update yarn monorepo (#10624) fix(deps): update dependency @swc/core to v1.5.7 (#10634) fix(deps): update dependency mini-css-extract-plugin to v2.9.0 (#10633) fix(deps): update dependency @sdl-codegen/node to v0.0.15 (#10632) chore(deps): update dependency @npmcli/arborist to v7.5.2 (#10628) fix(deps): update dependency find-my-way to v8.2.0 (#10631) chore(deps): bump @fastify/reply-from from 9.4.0 to 9.8.0 (#10629) fix(deps): update prisma monorepo to v5.14.0 (#10627) fix(deps): update dependency fastify to v4.27.0 (#10625) fix(deps): update docusaurus monorepo to v3.3.2 (#10626) fix(deps): update dependency react-helmet-async to v2.0.5 (#10621) chore(deps): update dependency @types/vscode to v1.89.0 (#10623) fix(deps): update dependency react-hook-form to v7.51.4 (#10622) chore(deps): update dependency @clerk/clerk-react to v4.31.1 (#10616) ...
Pulling out of draft @dthyresson - we still need to check with K6 or curl though if the store is isolated per request! |
…tuples-dbauth-mw * 'main' of github.com:redwoodjs/redwood: fix(deps): update dependency isbot to v5 (redwoodjs#10340) chore(deps): update dependency vscode-languageserver-protocol to v3.17.5 (redwoodjs#10351) chore(deps): update node.js to >=14.17 <=20.13 (redwoodjs#10368) fix(deps): update dependency graphql-sse to v2.5.3 (redwoodjs#10364) chore(deps): update dependency @supabase/supabase-js to v2.43.2 (redwoodjs#10365) chore(deps): update babel monorepo to v7.24.5 (redwoodjs#10614) fix(vite): Rename `serverAuthContext` to `serverAuthState` (redwoodjs#10653) feat(middleware): Add .shortCircuit to MiddlewareResponse (redwoodjs#10586) chore(ssr): Make entry.client.tsx better match standard entry.client (redwoodjs#10652) patch(crwa): Fix small annoyances (formatting, spell-check) (redwoodjs#10651) chore(ci): Update rsc readme (redwoodjs#10650) chore(serverAuth): Rename serverAuthContext to serverAuthState where relevant (redwoodjs#10643) chore(deps): Remove unused deps from prerender (redwoodjs#10649) Add missing rwjs/auth deps (redwoodjs#10648) feat(rsc-auth): Implement serverStore to hold and pass req info to RSC (redwoodjs#10585) chore(deps): Remove unused octokit package (redwoodjs#10645) chore(deps): bump @fastify/reply-from from 9.4.0 to 9.8.0 (redwoodjs#10644)
First pass at implementing a per-request store that allows:
This PR also implements execution of middleware in the RSC handler. Note that this is done in a "good enough" way currently, because the RSC handler doesn't use Fetch requests (but everything else does)
Important things to note:
rw dev
does not work in RSC yet