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

Add MOJO_PROMISE_DEBUG environment variable #1550

Merged
merged 1 commit into from
Sep 4, 2020
Merged

Conversation

kraih
Copy link
Member

@kraih kraih commented Aug 10, 2020

I'm not 100% sure about this feature, but it seems pretty useful for locating your unhandled rejected promises.

Instead of

Unhandled rejected promise: branches3 at /Users/sri/repo/mojo/lib/Mojo/Reactor/Poll.pm line 131.

you would see

Unhandled rejected promise: branches3 at /Users/sri/repo/mojo/lib/Mojo/Reactor/Poll.pm line 131.
-- Destroyed promise
Traceback (most recent call first):
  File "/Users/sri/repo/mojo/lib/Mojo/Promise.pm", line 55, in "Mojo::Promise"
  File "/Users/sri/repo/mojo/lib/Mojo/Promise.pm", line 94, in "Mojo::Promise"
  File "t/mojo/promise.t", line 444, in "main"
  File "/Users/sri/perl5/perlbrew/perls/perl-5.32.0/lib/site_perl/5.32.0/Test/Builder.pm", line 374, in "Test::Builder"
  File "/Users/sri/perl5/perlbrew/perls/perl-5.32.0/lib/site_perl/5.32.0/Test/Builder.pm", line 374, in "Test::Builder"
  File "/Users/sri/perl5/perlbrew/perls/perl-5.32.0/lib/site_perl/5.32.0/Test/More.pm", line 809, in "Test::More"
  File "t/mojo/promise.t", line 450, in "main"

is you set MOJO_PROMISE_DEBUG=1. Which made is very easy to conclude that line 444 is the real source of the forgotten promise.

@jberger
Copy link
Member

jberger commented Aug 10, 2020

I have always wanted something like this. When it was callbacks I tried several times to come up with basically this same thing but always got tripped up, mostly because I didn't have a good place to store info. With an object like Promise its much easier to tuck something in there. I haven't reviewed the code but I'm 100% on board with the concept!

Copy link
Member

@christopherraa christopherraa left a comment

Choose a reason for hiding this comment

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

👍 from me. Unhandled promises has tripped me up so many times. This is a great addition.

@mergify mergify bot merged commit e066ce7 into master Sep 4, 2020
@kraih kraih deleted the promise_debug branch January 17, 2021 17:17
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

Successfully merging this pull request may close these issues.

None yet

3 participants