Coroutine.yield() silences errors

After you call coroutine.yield(), errors just don’t show in output anymore @woot3


local c = coroutine.running()
delay(1, function()
print("done") --This prints
print(2+e) --The error for this doesn't show
1 Like

“Note that resume runs in protected mode. Therefore, if there is any error inside a coroutine, Lua will not show the error message, but instead will return it to the resume call.”

I don’t believe roblox changed up their implementation for resume from the out-of-box version of Lua.

Edit: adding assert should be an easy way to get your desired behavior. assert(coroutine.resume(c));


While tagging me will certainly bring this to my attention quicker, in the future, please verify your report is valid prior to doing so.

As @blobbyblob has explained this is intended behavior.


Looked around for a bit to find this was already a reported issue. Just encountered it myself and had me stumped for a few minutes as to why my code was just stopping at a seemingly normal statement. Turns out an error was being thrown and it was swallowed up because much earlier in the code I had used coroutine.yield() to wait for a bunch of coroutines to finish.

I think a good solution would be to have threads retain their normal error propagation behavior if that’s how they were first created.

yield isn’t the problem. It happens because you didn’t handle the values returned by resume:

The right solution to this would be a new function that resumes a thread while handling errors for you:

I see. I was aware resume was eating up the errors but I considered the behavior of doing so even on threads that weren’t started by the user a weird implementation detail. I do like the idea of a separate function for this kind of behavior, but I would also prefer Roblox change it to still propagate errors from those kind of threads.

It doesn’t seem obvious to the average user that errors would behave like this, in my opinion.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.