Hello everyone, I recently came into a problem. I am making an async event function and what it does is call a listener and wrap its error to see if it errored:
However, I noticed that doing so will return very poor call stacks that result almost impossible to debug in an extensive system. The only way I made the call stack appear was without wrapping the function however this will make so that it yields forever since âdoneâ is never updated after the listener is called.
Without pcall (Good):
With pcall (Bad):
The reason I am blurring the name is that it is my friend that encountered this problem with the module and asked me to not show his username
Donât call the function in protected mode. done += 1 will only fail to execute if the âlistenerâ function errors terminating the function call stack.
The thing is doing so would make it always yield. I am making a promise where you can yield until all events finished. This is why there is done += 1. If the function errors we will never know if it finished or if it errored.
The end goal is that it yields for 5 seconds and then errors with the desired call stack.
So emitting would be:
local Promise = myEmitter:EmitAsync("test");
warn("It is async!");
Promise:Yield();
warn("This will print but it errors in a separate thread. Therefore, the script continues executing");