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

Fix handling returned $promise from async method, closes #1990 #1991

Merged
merged 1 commit into from
Oct 17, 2022

Conversation

jhthorsen
Copy link
Member

Summary

Fix issue introduced in 166cedb when an async method returns a promise.

Motivation

@jberger reported the issue.

References

166cedb

t/mojo/promise_async_await.t Outdated Show resolved Hide resolved
marcusramberg
marcusramberg previously approved these changes Oct 15, 2022
Copy link
Member

@marcusramberg marcusramberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think i understand what this fixes. Head slightly hurts now tho. 🍻 needed to remedy this situation.

lib/Mojo/Promise.pm Outdated Show resolved Hide resolved
marcusramberg
marcusramberg previously approved these changes Oct 16, 2022
@jberger
Copy link
Member

jberger commented Oct 17, 2022

Bad news, running my example from #1990 on this branch the example hangs.

perl -Ilib -Mojo -MMojo::Base=-async_await -E 'async sub main { print await doit() } async sub doit { await Mojo::Promise->timer(1); return Mojo::Promise->resolve("hello") } main()->wait'

@jhthorsen
Copy link
Member Author

jhthorsen commented Oct 17, 2022

The (second) latest force push was pretty bad. I wonder if we can add this patch?

diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
index 1ced93691..ff9d404f6 100644
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -30,9 +30,11 @@ jobs:
         run: |
           cpanm -n --installdeps .
           cpanm -n Cpanel::JSON::XS EV Role::Tiny
+          cpanm -n Future::AsyncAwait
           cpanm -n Test::Pod Test::Pod::Coverage
       - name: Run tests
         run: prove -l t t/mojo t/mojolicious
         env:
+          TEST_ASYNC_AWAIT: 1
           TEST_POD: 1
           TEST_EV: 1

@jberger: Either way, you can try again 👍

Copy link
Member

@jberger jberger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that fixes my example, thanks.

@jberger
Copy link
Member

jberger commented Oct 17, 2022

I also agree about that change to the github test runner, please open a PR for that too.

Copy link
Member

@marcusramberg marcusramberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

third time is the charm, clearly ;-)

@mergify mergify bot merged commit e842d9f into main Oct 17, 2022
@jhthorsen jhthorsen deleted the jhthorsen/async-return-promise branch October 17, 2022 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants