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

Awaiting a non promise value results in error. #10481

Open
apollux opened this issue Sep 23, 2019 · 3 comments

Comments

@apollux
Copy link

commented Sep 23, 2019

Bug Report

Current Behavior
Awaiting a non promise value results in error: Unhandled rejection TypeError: A value undefined was yielded that could not be treated as a promise

Input Code

async function someFunction() {
        const noop = () => {};
        await noop();
}

Expected behavior/code
The non promise return value of noop should be wrapped in a resolved promise.

Babel Configuration (.babelrc, package.json, cli command)

{
    "plugins": [
        ["@babel/plugin-transform-async-to-generator", {
            "module": "bluebird",
            "method": "coroutine"
          }],
        "@babel/plugin-transform-runtime",
        "@babel/plugin-syntax-dynamic-import"
    ],
    "presets": ["@babel/preset-env"]
}

Environment

  • Babel version(s): 7.6.0
  • Node/npm version: v10.16.0
  • OS: Windows 10
  • Monorepo: no
  • How you are using Babel: loader

Possible Solution
Perhaps that adding a yieldhandler that wraps non promise values in a resolved promise is all that is needed.
http://bluebirdjs.com/docs/error-explanations.html#error-a-value-was-yielded-that-could-not-be-treated-as-a-promise
http://bluebirdjs.com/docs/api/promise.coroutine.addyieldhandler.html

Additional context/Screenshots
Unhandled rejection TypeError: A value undefined was yielded that could not be treated as a promise See http://goo.gl/MqrFmXFrom coroutine: at Promise.coroutine (http://localhost:3000/vendor.bundle.js?57ffae13013e8a21a458:26718:17)

@babel-bot

This comment has been minimized.

Copy link
Collaborator

commented Sep 23, 2019

Hey @apollux! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

@nicolo-ribaudo

This comment has been minimized.

Copy link
Member

commented Sep 23, 2019

You say that you are using Babel 6, but all your plugins are Babel 7. Which version are you using?

Also, since you can await any value, this looks like a missing feature in Bluebird which doesn't allow yielding some values.

@apollux

This comment has been minimized.

Copy link
Author

commented Sep 23, 2019

You say that you are using Babel 6, but all your plugins are Babel 7. Which version are you using?

Also, since you can await any value, this looks like a missing feature in Bluebird which doesn't allow yielding some values.

Copy paste from wrong environment, updated the info. Using babel 7.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.