Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception swallowed in Task #163

Open
jmatsushita opened this issue Nov 12, 2017 · 3 comments
Open

Exception swallowed in Task #163

jmatsushita opened this issue Nov 12, 2017 · 3 comments

Comments

@jmatsushita
Copy link

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
jmatsushita added a commit to iilab/folktale that referenced this issue Nov 12, 2017
@robotlolita
Copy link
Member

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.

@jmatsushita
Copy link
Author

jmatsushita commented Nov 18, 2017

The conditional assertion was confusing indeed. I've hopefully clarified the intent now with the updated PR description.

@yormi
Copy link

yormi commented Dec 17, 2017

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 .maps 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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants