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

perf(v2): convert synchronous filewrite to asynchronous #2936

Merged
merged 3 commits into from
Jun 15, 2020

Conversation

moonrailgun
Copy link
Contributor

Motivation

I encounter same problem like #2539 in alpha.50 and discover its have been resolved. But the solution to fix is sync way.

Have you read the Contributing Guidelines on pull requests?

Yep

Test Plan

Build website and make sure that the build/blog/atom.xml, build/blog/rss.xml and build/sitemap.xml files are still work correct.

Related PRs

(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jun 15, 2020
@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Jun 15, 2020

Deploy preview for docusaurus-2 ready!

Built with commit b7df851

https://deploy-preview-2936--docusaurus-2.netlify.app

Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

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

Thanks, that looks good to me

For consistency I'd prefer we move to async/await everywhere

try {
fs.writeFileSync(feedPath, feedContent);
} catch (err) {
return fs.outputFile(feedPath, feedContent).catch((err) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi

What about using async/await here too. I think we should progressively update to async/await everywhere for consistency

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @slorber ,
I know about that. But this a Promise.all, and should return promise. I dont think async/await is suitable.

async/await is good syntax but not fit any case

If you still persist in it, i will update it.

Thanks for you review

Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the problem with Promise.all and async/await?

We already have this in other places already

Copy link
Collaborator

Choose a reason for hiding this comment

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

like in packages/docusaurus-plugin-content-docs/src/index.ts:464

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, just think this too redundancy —— its unnecessary to write async/await.

But if that is a project rule, i will comply with it.

@slorber slorber merged commit 930222e into facebook:master Jun 15, 2020
@slorber
Copy link
Collaborator

slorber commented Jun 15, 2020

thanks

@moonrailgun
Copy link
Contributor Author

my pleasure

@slorber slorber added the pr: performance This PR does not add a new behavior, but existing behaviors will be more memory- / time-efficient. label Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: performance This PR does not add a new behavior, but existing behaviors will be more memory- / time-efficient.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants