folktale
folktale copied to clipboard
Exception swallowed in Task
When using a require()
d missing import, which should be undefined, inside a Task
the exception is swallowed.
Steps to reproduce
See upcoming test.
Expected behaviour
An exception to be raised
Observed behaviour
The program doesn't raise an exception or not even an unhandledRejection.
Environment
- OS: OSX
- JavaScript VM: node 8.5
- Folktale version: 2.0.1
Mmh, I'm confused about that PR. The tests pass when fixing the check in the catch
branch.
In any case, Task shouldn't be swallowing any errors, but it's quite possible that some weird interaction between Task and Promises is doing that. Hard to say what without more context though.
The conditional assertion was confusing indeed. I've hopefully clarified the intent now with the updated PR description.
I encountered a similar problem if I try to use jsonwebtoken
.
No matter if I use Task.fromNodeback(jwt.sign)
or make my own task with:
const t = task(resolver =>
jwt.sign(payload, secret, (err, _) =>
err ? resolver.reject() : resolver.resolve()
)
t.run().promise()
would resolve but
await t
.map(_ => { throw new Error('abc') })
.run()
.promise()
will swallow the error and hang there.
So far, haven't encounter any problem neither if I use the synchronized version: t = Task.of(jwt.sign(payload, secret))
or any other circumstances. Just with async jwt stuff.
Oh and if I console.log
, I can see that the .map
s are executed but never .listen
neither anything awaiting the promise.
~~No problem with .listen
if not using .promise()
~~ not true after all...
node: 9.3.0 OS: Linux folktale: 2.0.1
Hope this helps...
edit: Just tried with data.task
and couldn't make it work either =/ Maybe it's the library (don't get how could that be) or me doing something wrong...