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

chore(gatsby): cleanup api runner promises #19664

Merged
merged 14 commits into from
Nov 26, 2019
Merged

Conversation

pvdz
Copy link
Contributor

@pvdz pvdz commented Nov 20, 2019

This attempts to remove a bunch of BlueBird promises from the api runner, in favor of native Promises.

It also cleans up the core of the api-runner by eliminating a bunch of controls that would never really be used due to how promises get resolved and non-blocking works.

@pvdz pvdz force-pushed the refactor-api-runner branch 2 times, most recently from c72cb4d to c2c1e0a Compare November 20, 2019 19:58
@vladar
Copy link
Contributor

vladar commented Nov 21, 2019

You could use async iterators with for await syntax unless I am missing something. They are available natively in node 10 but I guess babel/corejs have some polyfills for earlier versions.

@pvdz
Copy link
Contributor Author

pvdz commented Nov 21, 2019

It's an excellent point :)
Since we're targeting node 8 I'm going to hold off on that as I fear the Babel transform is going to be worse than what I have right now. Once we're on 10+ we can switch over and it would be a small change.

@pvdz
Copy link
Contributor Author

pvdz commented Nov 21, 2019

Had to test a few cases and conclusion is that this is not a safe refactor.

https://jsfiddle.net/3vuk4yfj/

In short, the refactor would not allow you to resolve the promise regarless of recursive ("cascading") calls. And it would not wait for all apis of the same name to finish before resolving the outer promise, which is also breaking the current model. So I'll go back to before that.

@pvdz pvdz force-pushed the refactor-api-runner branch 2 times, most recently from 8cede86 to 16f89c5 Compare November 21, 2019 11:26
@pvdz pvdz marked this pull request as ready for review November 21, 2019 11:34
@pvdz pvdz requested a review from a team as a code owner November 21, 2019 11:34
@pvdz pvdz removed the status: WIP label Nov 21, 2019
Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

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

At first glace this looks 👌. I've added 2 comments, nothing major. I'll be testing this on a few sites.

@pvdz pvdz force-pushed the refactor-api-runner branch from 16f89c5 to 5b044eb Compare November 26, 2019 15:00
@pvdz
Copy link
Contributor Author

pvdz commented Nov 26, 2019

(rebased)

@wardpeet wardpeet merged commit c523e22 into master Nov 26, 2019
@wardpeet wardpeet deleted the refactor-api-runner branch November 26, 2019 16:17
pvdz added a commit that referenced this pull request Jan 24, 2020
pvdz added a commit that referenced this pull request Jan 24, 2020
pieh pushed a commit to pieh/gatsby that referenced this pull request May 17, 2020
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.

4 participants