-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Astro Info
Astro v5.6.0
Node v18.20.3
System Linux (x64)
Package Manager npm
Output server
Adapter @astrojs/node
Integrations none
Describe the Bug
We've been seeing the following error a lot in our server logs recently:
15:01:59 [ERROR] ActionNotFoundError: The server received a request for an action named `..........` but could not find a match. If you renamed an action, check that you've updated your `actions/index` file and your calling code to match.
at AppPipeline.getAction (file:///app/dist/server/chunks/_@astrojs-ssr-adapter_T2VsY-t8.mjs:276:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.handler (file:///app/dist/server/chunks/index_DhTrmX1a.mjs:995:28)
at async Module.POST (file:///app/dist/server/pages/_actions/_---path_.astro.mjs:9:18)
at async renderEndpoint (file:///app/dist/server/chunks/astro/server_Bdd2vCsi.mjs:487:18)
at async lastNext (file:///app/dist/server/chunks/index_DhTrmX1a.mjs:1979:23)
(The action name '........' is actually this value, so I did not obscure it or something. (In case this matters)).
I think these are bots that are trying to break the system somehow.
There currently doesn't seem to be a way to catch these errors more gracefully (update: not even in middleware it seems!), like sending these requests to a 404 page or to run any other code in case an action is not found.
Maybe in the actions setup, there should be a 'onNotFound' property or something, that gets called if an action is not found?
import { ActionError, defineAction } from 'astro:actions';
export const server = {
hi: defineAction({
handler: async () => {
return 'Hi';
},
}),
onNotFound: (data, ctx) => {
// do something like maybe blocking the ip, or adding it to a ban-list...
return Response({}, { status: 404 });
}
};What's the expected result?
So not so much a different expected result, but more the wish to catch these errors somehow to be able to act upon them.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-1shwwyyj?file=src%2Fpages%2Findex.astro
Participation
- I am willing to submit a pull request for this issue.