laverdet/node-fibers

Using instanceof Error for return of fiber.

Closed this issue · 3 comments

I noticed that when I use an Error object for the return of a fiber a throw happens with the returned value.

I.E.

CustomFuture.fiber.run(new Error());
return CustomFuture.fiber.yield();

Obviously with a lot more code to support the Future, but the general problem is this ends up surfacing as an uncaught exception. Is this by design? Can we not ever return instances of Error from a fiber?

I'm also not able to track down exactly where the 'throw' occurs because it uses the instance of Error.

I was thinking this might have something to do with gc and unwinding a fiber, but I'm not sure why unwinding a fiber would throw the value passed to .run()?

This sounds like an error in your code, without more information it's impossible to say anything more.

Ok. I'll keep digging. Thanks.