early bail out for apps without server actions #87775
Open
+85
−73
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
this change moves the hasServerActions() check to occur immediately after determining that a request could potentially be a server action, before any expensive operations like CSRF validation, header parsing, or body processing.
apps without server actions were still performing significant CPU work (CSRF checks, header parsing, etc.) when receiving spam requests that mimic server action calls, leading to high CPU usage even though no actions exist. (this was an issue in my app, and its what caused my next.js site go down. see #87771
by checking hasServerActions() early, we can immediately return a 404 for fetch actions or null for non-fetch requests, avoiding all the unnecessary processing. This significantly reduces CPU overhead for spam requests on pages that don't use server actions.