Coroutine error stack traces give no clue about error location

I’m using coroutines in JS. When my code throws an exception, I can’t see the source location. I understand that much of the stack will be in the coroutine library, but I expected the top of the stack (ie, closest to the error) to still show my code. However, it doesn’t. Obviously this makes debugging much more difficult. Is there anything that can be done to alleviate this?

Here’s a screenshot of an example stacktrace:

13%20AM

1 Like

If I am not mistaken, this is not the stack trace to the location where the error happened. Instead, it is the stack trace to the location where the error is logged.

To see the error’s stack trace, look into the error object’s stack property.

(This is not caused by coroutines. I believe this is the way how JavaScript Console.error() function works)

Thank you! I can’t expand that stack property in Safari’s dev tools, but I can in Chrome. So now I see it’s a much bigger string containing the useful stack trace. It’s not ideal, because the error locations are all pointing into the compiled js files, and it’s not rendered as links, but it shows me something that is much better.

I think I see what you mean – the coroutine library is catching and logging the error, while in other code the error was getting back to the browser’s event loop. I wonder if it’s possible for the coroutine library to log the error differently, so that it shows the more useful stack trace.

Yes, I would like that, too. It annoys me regularly.