Running SvelteKit in Cloudflare

I am moving my SvelteKit from Vercel Edge, which from my understanding is Cloudflare, to Cloudflare directly. However, I get this message when I run a form action:
Error: Can only read the current request event inside functions invoked during `handle`, such as server `load` functions, actions, endpoints, and other server hooks. In environments without `AsyncLocalStorage`, the event must be read synchronously, not after an `await`."
Error: Can only read the current request event inside functions invoked during `handle`, such as server `load` functions, actions, endpoints, and other server hooks. In environments without `AsyncLocalStorage`, the event must be read synchronously, not after an `await`."
This is caused from getRequestEvent in my code which needs AsyncLocalStorage. I didn't have to configure anything fancy in Vercel Edge for this to work, but it won't work in Pages. There is no nodejs_compat nor the preferable nodejs_als available. How do I get this to work? J
No description
1 Reply
jdgamble555
jdgamble555OP5d ago
this seems to be the issue, which I don't know how to solve - https://community.cloudflare.com/t/compatibility-flags-nodejs-compat-and-nodejs-als-not-available/791040 Got it working by manually adding nodejs_als flag... it wasn't saving before, but I must have not entered it correctly!...

Did you find this page helpful?