-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
feat(gatsby-core-utils): improve fetch-remote-file #34758
Conversation
9219a41
to
c221936
Compare
@@ -0,0 +1,269 @@ | |||
import fs from "fs-extra" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file stayed untouched
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed a few things after all
c221936
to
c862f5a
Compare
c862f5a
to
3a30cf4
Compare
@@ -380,316 +363,6 @@ describe(`fetch-remote-file`, () => { | |||
expect(gotStream).toBeCalledTimes(1) | |||
}) | |||
|
|||
it(`only writes the file once when multiple workers fetch at the same time`, async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving this to integration test
7114493
to
7d4a00e
Compare
...gatsby-source-wordpress/src/steps/source-nodes/create-nodes/create-remote-file-node/index.js
Outdated
Show resolved
Hide resolved
7d4a00e
to
e40f1f6
Compare
// Called if we stall for 30s without receiving any data | ||
const handleTimeout = async (): Promise<void> => { | ||
fsWriteStream.close() | ||
await fs.remove(tmpFilename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made this async instead of sync for better windows support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What the catch with sync fs.remove
on windows?
} | ||
|
||
fsWriteStream.close() | ||
await fs.remove(tmpFilename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made this async instead of sync for better windows support
|
||
// We have an incomplete download | ||
if (!haveAllBytesBeenWritten) { | ||
await fs.remove(tmpFilename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made this async instead of sync for better windows support
f813d2a
to
b564e98
Compare
0412bac
to
56b467b
Compare
* feat(gatsby-core-utils): improve fetch-remote-file * feat: use cacheKey in fetch-remote-file * use async file operations * Improve tests + low hanging fruit * revert wordpress * feat: make sure 304 works * fix jest config wordpress * add integration test * update tests
Description
Improving remote fetch by adding two bits:
fetch-remote-file is now decoupled from gatsby's cache. It still functions roughly the same but if you give it a proper cacheKey like contentdigest of a node we can keep the file around between builds even if package.json or gatsby got changed.
Documentation
FetchRemoteFile is not documented yet, will do that afterwards.
TODO