haxe-coroutines icon indicating copy to clipboard operation
haxe-coroutines copied to clipboard

Call stack

Open RealyUniqueName opened this issue 7 years ago • 2 comments

haxe.CallStack.callStack() and haxe.CallStack.exceptionStack() should contain valid stack including suspend points. Maybe add a Suspend(item:StackItem) constructor to StackItem enum. Example:

class Test {
  async function root() {
    await timerDelay(3000);
    await level1();
  }

  async function level1() {
    level2();
  }
  
  async function level2() {
    throw "Terrible error";
  }
}

Exception stack for Terrible error should be like this:

Method('Test', 'root');
Suspend(Method('Test', 'level1'));
Method('Test', 'level2');

RealyUniqueName avatar Aug 25 '17 11:08 RealyUniqueName

That's an important thing to consider. However, having this always enabled will have a negative effect on performance, so maybe this should only be enabled with -debug or some other flag.

nadako avatar Sep 18 '17 19:09 nadako

In my implementation i collect positions of async stack at compile time as strings, which is pretty cheap. And then attach a runtime stack clipped from the place it was requested to the nearest await.

RealyUniqueName avatar Sep 18 '17 20:09 RealyUniqueName