You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: ensure remote file downloads are queued in all cases (#34414)
* fix: move queue from remote file node creation to remote file fetching
* reduce number of concurrent requests per CPU core to 50
* rename worker function to mark it as worker
* improve typings
* refactor: remove GATSBY_EXPERIMENTAL_REMOTE_FILE_PLACEHOLDER flag
* fix typing?
Co-authored-by: Ward Peeters <[email protected]>
* Index of promises resolving to File node from remote url
156
87
*/
157
88
constprocessingCache={}
158
-
/**
159
-
* pushTask
160
-
* --
161
-
* pushes a task in to the Queue and the processing cache
162
-
*
163
-
* Promisfy a task in queue
164
-
* @param {CreateRemoteFileNodePayload} task
165
-
* @return {Promise<Object>}
166
-
*/
167
-
constpushTask=task=>
168
-
newPromise((resolve,reject)=>{
169
-
queue.push(task,(err,node)=>{
170
-
if(!err){
171
-
resolve(node)
172
-
}else{
173
-
reject(`failed to process ${task.url}\n${err}`)
174
-
}
175
-
})
176
-
})
177
89
178
90
/***************
179
91
* Entry Point *
@@ -202,20 +114,6 @@ module.exports = function createRemoteFileNode({
202
114
ext =null,
203
115
name =null,
204
116
}){
205
-
if(showFlagWarning){
206
-
showFlagWarning=false
207
-
// Note: This will use a placeholder image as the default for every file that is downloaded through this API.
208
-
// That may break certain cases, in particular when the file is not meant to be an image or when the image
209
-
// is expected to be of a particular type that is other than the placeholder. This API is meant to bypass
210
-
// the remote download for local testing only.
211
-
console.info(
212
-
`GATSBY_EXPERIMENTAL_REMOTE_FILE_PLACEHOLDER: Any file downloaded by \`createRemoteFileNode\` will use the same placeholder image and skip the remote fetch. Note: This is an experimental flag that can change/disappear at any point.`
213
-
)
214
-
console.info(
215
-
`GATSBY_EXPERIMENTAL_REMOTE_FILE_PLACEHOLDER: File to use: \`${process.env.GATSBY_EXPERIMENTAL_REMOTE_FILE_PLACEHOLDER}\``
216
-
)
217
-
}
218
-
219
117
// validation of the input
220
118
// without this it's notoriously easy to pass in the wrong `createNodeId`
221
119
// see gatsbyjs/gatsby#6643
@@ -245,11 +143,13 @@ module.exports = function createRemoteFileNode({
245
143
246
144
if(!url||isWebUri(url)===undefined){
247
145
returnPromise.reject(
248
-
`url passed to createRemoteFileNode is either missing or not a proper web uri: ${url}`
146
+
newError(
147
+
`url passed to createRemoteFileNode is either missing or not a proper web uri: ${url}`
0 commit comments