W
Wasp-lang•4mo ago
Ramon

Infinite loop if updateCurrentUser returns void

Hi, I'm using opensaas with wasp v0.14.0. I tried to update the updateCurrentUser function from actions.ts to return "void" as the result is not being used in App.tsx. I also added some logs as you can see in the screenshot. My surprise was that when I changed it to return a void and no result, it created an infinite loop which slowed down the website performance. When I go back to the current version on wasp (which returns the User entity) the infinite loop stops. Could you please confirm if this is a bug in wasp? Thanks!
No description
No description
10 Replies
kapa.ai
kapa.ai•4mo ago
Hi @Ramon. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Hmm, I don't know enough to give you a confident answer yet. The knowledge sources provided do not contain information about an infinite loop issue when the updateCurrentUser function returns void in Wasp. However, it's worth noting that in Wasp, actions are expected to return a result. For instance, in the Wasp documentation (https://wasp-lang.dev/docs/data-model/operations/actions#implementing-actions-in-node), the createTask action returns the newly created task, and the markTaskAsDone action returns void because it doesn't need to return anything. If you're experiencing an infinite loop, it might be due to how your application is handling the void return type. It's recommended to check how your application is using the result of the updateCurrentUser action. For more detailed help, I would recommend reaching out to the Wasp community or checking the Wasp documentation. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Ramon, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Ramon
RamonOP•4mo ago
No description
miho
miho•4mo ago
One for @martinsos and @Vinny (@Wasp)
Ramon
RamonOP•4mo ago
Hey @Vinny (@Wasp)! I have received a notification but your reply has been removed 😯 Do you know how to fix this issue in the useEffect?
Vinny (@Wasp)
Vinny (@Wasp)•4mo ago
Hey I’m working on a possible solution now. I’ll send you the link ASAP 🙂 Hey. I thought about this for a while and tried out different solutions, but I don't really see an issue with the current implementation. Are you still having this problem? Can you restart your wasp app? if it's still on an infinate loop, can you share the code in code blocks ?
Vinny (@Wasp)
Vinny (@Wasp)•4mo ago
you can formate typescript code like this
No description
Vinny (@Wasp)
Vinny (@Wasp)•4mo ago
The one thing I think might fix the issue, if you're still having it, is to await the context.entities.User.update() call
Ramon
RamonOP•4mo ago
Indeed @Vinny (@Wasp) , adding the await seems to fix the issue. I still don't understand why, do you know it? I saw that the updateCurrentUser function is the only one that was missing the await, so maybe you want to update it in the opensaas template as well!
Vinny (@Wasp)
Vinny (@Wasp)•4mo ago
the function updateCurrentUser is a promise, so we need to await it, otherwise it might call the function again before it's able to finish updating the user in the database
Vinny (@Wasp)
Vinny (@Wasp)•4mo ago
GitHub
Improve updating user lastActiveTimestamp by vincanger · Pull Reque...
there was an issue where a user was getting an infinite loop on the updateCurrentUser action, most likely because it wasn't being awaited on the client side, so I fixed that here.
Want results from more Discord servers?
Add your server