Use "waitUntil" from within the next code #596
-
Is there a way to call |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 13 replies
-
Hi @SamyPesse, unfortunately currently there isn't 😓 It's not difficult for us to implement (as you can see for example we already have a PR that would implement that: #450), but the team hasn't been able to agree on an API for this I've been trying to push for a resolution but different opinions combined with non next-on-pages related work has caused this to be put a bit on the back burner, sorry about that, I do need to try to resolve this soon 🙏 |
Beta Was this translation helpful? Give feedback.
-
@dario-piotrowicz I'd like your input on something: We are still facing errors
The reason is that we have a logic to run an async function only once at the same time it's running (ex, around a fetch). Since Cloudflare Workers handle multiple requests in the JS context, the global variables are shared. To fix it, I tried to use a WeakMap where the key will be an object unique to the request. Unfortunately, I can't access the Then I tried to use I'm curious why you are using a global proxy instead of directly accessing the object from the async local storage. |
Beta Was this translation helpful? Give feedback.
@SamyPesse I've just merged #659 which introduces a new utility (
getRequestContext
) that gives you access towaitUntil
.You can use it by installing the latest beta release and it will be available in the next stable release we make.
If you want, please give it a try and let me know if that works well for you 🙂