Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Coroutine error fails to specify what line of code is causing it, why?

Asked by 4 years ago
Edited 4 years ago

My question is quite simple, I was recently play-testing my game and the output is suddenly spammed with this error:

14:58:08.503 - cannot resume dead coroutine
14:58:08.504 - Stack Begin
14:58:08.505 - Stack End
14:58:08.506 - cannot resume dead coroutine
14:58:08.506 - Stack Begin
14:58:08.507 - Stack End
14:58:08.508 - cannot resume dead coroutine
14:58:08.509 - Stack Begin
14:58:08.509 - Stack End
14:58:08.513 - cannot resume dead coroutine
14:58:08.513 - Stack Begin
14:58:08.514 - Stack End
14:58:08.519 - cannot resume dead coroutine
14:58:08.520 - Stack Begin
14:58:08.520 - Stack End

Before you say anything, I know what the error means and I have a general idea of where the error is coming from, as it happens when I fire a certain weapon so I am not asking for help on how troubleshoot. And that's the whole problem - I shouldn't have to "guess and check" when it comes to locating an error. Its location should be clearly defined and that's what I am failing to see. Am I missing something here or is this an intended feature? Thanks for your time in advance.

Edit:

I did some further experimentation with coroutines, and apparently the following code causes the same error, but for some strange reason it is not consistent with what I am experiencing because it actually returns the line of code causing the error:

local Test = coroutine.wrap(function()
    print(1)
end)
Test()
Test()

The first Test() obviously returns 1 in the output, while the second one produces the previous error but also includes the location:

16:16:00.822 - Workspace.Script:5: cannot resume dead coroutine
16:16:00.824 - Stack Begin
16:16:00.825 - Script 'Workspace.Script', Line 5
16:16:00.826 - Stack End
0
I would assume that this message isn't treated as an error internally, just a warning of sorts, which is why you don't get a stacktrace. Likely intended, because not being able to start a coroutine that's already run probably won't(?) result in a fatal error.  whenallthepigsfly 541 — 4y
0
What's the code? I can't reproduce it with what I would think would trigger it. whenallthepigsfly 541 — 4y
0
I'm pretty sure the error is returned when you end up calling a defined coroutine function more than one time. Just edited the question with an example of what causes this error. TheLlamaAlpaca 29 — 4y

Answer this question