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

Properly return a bluebird promise #8988

Merged
merged 1 commit into from
Sep 7, 2017
Merged

Conversation

ErisDS
Copy link
Member

@ErisDS ErisDS commented Sep 7, 2017

This really didn't make sense to me at first - but the problem is that got() itself returns the wrong kind of promise. We have to instead wrap it. Really annoying because it makes for ugly code, but this is the only way to make sure we can use function predicates everywhere.

FYI I have this wrong in other code 🙈 😞

refs #8980

  • ☹️ apparently this is actually the only way

refs TryGhost#8980

- ☹️ apparently this is actually the only way
@aileen aileen merged commit 45fd2d4 into TryGhost:master Sep 7, 2017
@ErisDS ErisDS deleted the got-util branch September 8, 2017 13:51
@kirrg001
Copy link
Contributor

@AileenCGN

Could you please add a test for this PR? And could you double check the got - e.g. they add a cancel method. I haven't investigated yet.

I would like to figure out if we can remove the promise wrapper, because of 7353c87.

kirrg001 added a commit that referenced this pull request Dec 13, 2017
refs #9178

- next steps are to
  A: test if global.Promise works with `got` (see #8988 (comment))
  B: re-use request utility everywhere
  C: request lib requires data/validator, which is dirty
@aileen
Copy link
Member

aileen commented Dec 14, 2017

I would like to figure out if we can remove the promise wrapper

If I remember correctly, we had to wrap the got request into a Bluebird Promise, as catch predicates didn't work without, see here.

@kirrg001
Copy link
Contributor

I would like to figure out if we can remove the promise wrapper, because of 7353c87.

So we need to test if we can now remove this because of ^. Do you have time to check that?

@aileen
Copy link
Member

aileen commented Dec 14, 2017

I will check tomorrow and try to optimise the tests which needed this wrap.

@aileen
Copy link
Member

aileen commented Dec 15, 2017

@kirrg001 Submitted a PR #9343
You were right, the wrap is not needed anymore.

@kirrg001
Copy link
Contributor

That is cool!

aileen added a commit to aileen/Ghost that referenced this pull request Jan 2, 2018
refs TryGhost#9178, refs TryGhost#8988

With TryGhost@7353c87 we use Bluebird globally for Promises. Therefore, the request lib doesn't need to be wrapped in a bluebird Promise anymore.

This was originally done, so we can work with catch predicated in our image-size lib.

Updated the tests to proof, that the catch predicates work.

The tests fail, as soon as the Promise overwrite is commented out.
kirrg001 pushed a commit that referenced this pull request Jan 2, 2018
refs #9178, refs #8988

With 7353c87 we use Bluebird globally for Promises. Therefore, the request lib doesn't need to be wrapped in a bluebird Promise anymore.

This was originally done, so we can work with catch predicated in our image-size lib.

Updated the tests to proof, that the catch predicates work.

The tests fail, as soon as the Promise overwrite is commented out.
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.

3 participants