-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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
Client cannot recover from version skew #75541
Comments
Thank you for the link, @leerob. It's not entirely clear from the documentation that the encryption key affects the non-deterministic action IDs. If it does, that doesn't fully address this issue. Even if the encryption key is kept the same across builds it is still possible to get a different action ID and the client still has no way to recover when that happens. I couldn't find any documentation anywhere on how action IDs are generated. Is it some sort of hash involving the file name, function name, and the |
After some more experimentation the following code also does not catch any client-side errors, even though the server output indicates that the action cannot be found: "use client";
import { logServer2 } from "./actions";
export function CallServerActionButton() {
return (
<button
onClick={async () => {
try {
await logServer2();
} catch (e) {
// This never catches anything, even if the action is not found server-side
console.error("Error in CallServerActionButton:", e);
}
}}
>
Server Action
</button>
);
} |
Having the same issue on a Next.js ^15.0.2 app deployed on AWS with SST v2.
This has been really tough to troubleshoot since there are no client-side errors, no way to identify which action is causing it, and no way to track it down. We also can’t determine the user’s experience. We assume the action isn’t executed, leaving the app broken without any way to handle or provide feedback to the user. |
I tried to open an issue to get clarity around this in docs and it was immediately closed by a bot. |
@mbranch For that it's working as expected because we need a GitHub repo link (you provided a link to an issue instead)—the bot should not run when you run the Documentation issue template. |
@knpwrs Did you confirm this with your reproduction? I am not seeing the Environment Variable in in your reproduction. I do agree we could improve our Documentation here, so taking a look at that as well— |
@samcx the reproduction is if you rename a function or do a similar refactoring such as moving a function. Clients which have not refreshed between deployments will attempt to call non-existing actions and the client has no way to recover —- no errors are thrown, and even if one were to install a service worker to intercept fetch calls the response code is 200, even though something like 404 would probably be more appropriate (though given that the network call is abstracted away this doesn’t matter as much as just making some sort of error the client can recover from). |
Link to the code that reproduces this issue
https://github.com/knpwrs/nextjs-skew-recovery-bug
To Reproduce
npm run build
npm start
http://localhost:3000
and make sure the browser development tools are open.Server Action
button.200
response code indicating no errors and atext/x-component
mime type.logServer
function inactions.ts
and update the import and usage incomponents.tsx
to match (for instance,logServer
can be renamed tologServer2
).npm run build
npm start
Server Action
button.[Error: Failed to find Server Action "006c3c7b08402d18959b82a9692db1011f32bcc8fd". This request might be from an older or newer deployment. Original error: Cannot read properties of undefined (reading 'workers')]
200
response code indicating no errors and atext/html
mime type.Throw Error
button. Observe an uncaught error in the console.Note that I couldn't get
error.tsx
orglobal-error.tsx
to work for either the failed function call or the thrown client-side error.Current vs. Expected behavior
Currently the client is not able to recover from version skew when a server action cannot be called. Everything appears normal to the client.
I would expect the error boundary to catch an error so the client can refresh and recover.
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 24.2.0: Fri Dec 6 19:01:59 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6000 Available memory (MB): 32768 Available CPU cores: 10 Binaries: Node: 23.6.0 npm: 10.9.2 Yarn: 1.22.19 pnpm: 9.12.2 Relevant Packages: next: 15.2.0-canary.33 // Latest available version is detected (15.2.0-canary.33). eslint-config-next: N/A react: 19.0.0 react-dom: 19.0.0 typescript: 5.7.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Server Actions, Error Handling
Which stage(s) are affected? (Select all that apply)
next start (local), Other (Deployed), Vercel (Deployed)
Additional context
This is particularly problematic given the following quote from this blog post:
I couldn't find any documentation about this. It appears that action IDs can change at any time and clients which haven't refreshed yet won't have any way to deal with this.
The text was updated successfully, but these errors were encountered: