-
-
Notifications
You must be signed in to change notification settings - Fork 125
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
add api example #743
add api example #743
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
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.
most cases are covered by server actions
I noticed something recently that React only allows one server action running at the backend at the same time. So now I think this causes server action is not suitable for some cases if there're many users doing some operation in the same time.
https://react.dev/reference/rsc/use-server
Server Actions are designed for mutations that update server-side state; they are not recommended for data fetching. Accordingly, frameworks implementing Server Actions typically process one action at a time and do not have a way to cache the return value.
BTW, this is not same as the normal restful API, that processes multiple POST queries
simultaneously.
Some similar issue: vercel/next.js#64396
I wonder if it's a framework choice or a React rule. Anyway, I believe #329 is unavoidable for us. I'll work on it, but it will take time. There are some other tasks with priority (not because of the use case, but the internal architecture.) |
I believe this is React behavior, which will prohibit race conditions in the React backend at all |
By the way, for data fetching, we should use server components and rsc is capable of sending promises, so technically we can wrap the api with rsc. |
While we wait for #329 (which takes time to design and implement, and we believe most cases are covered by server actions), we can use the low-level middleware api.