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

Bug: Aigle tries to call then even if it's not a function #136

Closed
adrian-gierakowski opened this issue Oct 1, 2020 · 1 comment · Fixed by #138
Closed

Bug: Aigle tries to call then even if it's not a function #136

adrian-gierakowski opened this issue Oct 1, 2020 · 1 comment · Fixed by #138
Labels
Projects

Comments

@adrian-gierakowski
Copy link
Contributor

This is different to the behaviour of native nodejs Promise (which only treats a value as a promise if then is a function):

> node --eval 'Promise.resolve({ then: 1 }).then(x => console.log(x))'
{ then: 1 }

Aigle:

> node --eval 'require("aigle").resolve({ then: 1 }).then(x => console.log(x))'
/Users/adrian/aigle-test/node_modules/aigle/lib/internal/util.js:169
  promise.then(resolve, reject);
          ^

TypeError: promise.then is not a function
    at callThen (/Users/adrian/aigle-test/node_modules/aigle/lib/internal/util.js:169:11)
    at callReceiver (/Users/adrian/aigle-test/node_modules/aigle/lib/internal/util.js:165:3)
    at Function._resolve [as resolve] (/Users/adrian/aigle-test/node_modules/aigle/lib/aigle.js:3746:3)
    at [eval]:1:18
    at Script.runInThisContext (vm.js:120:20)
    at Object.runInThisContext (vm.js:311:38)
    at Object.<anonymous> ([eval]-wrapper:10:26)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at evalScript (internal/process/execution.js:94:25)
    at internal/main/eval_string.js:23:3

Tested with:

> node --version
v12.18.2
@suguru03
Copy link
Owner

suguru03 commented Oct 1, 2020

Hi @adrian-gierakowski !
Thanks for reporting the issue and catching the bug!

We need to check this condition strictly. ✍️
https://github.com/suguru03/aigle/blob/master/lib/internal/util.js#L147

I welcome your PR 😄

@suguru03 suguru03 added the bug label Oct 1, 2020
@suguru03 suguru03 added this to To do in v1.x Oct 1, 2020
v1.x automation moved this from To do to Done Nov 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
v1.x
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants